Class: Arbor::Peakflow::Client
- Inherits:
-
Object
- Object
- Arbor::Peakflow::Client
- Includes:
- Alerts, CP5500, Managed_Object, Mitigations, Reports, Routers, TMS_Appliance, TMS_Ports, Traffic
- Defined in:
- lib/arbor_peakflow_ruby/client.rb
Overview
Client
The Arbor Peakflow client in charge of using Hurley to communicate with the Arbor devices.
Parameters
-
hosts, host, urls, or url: The location of the Arbor Peakflow device cluster.
-
api_key: The API key to be used when communicating with the Arbor Peakflow API.
-
ssl_verify: (Optional) Boolean value stating whether you would like to verify the SSL certificates. Defaults to false.
-
ca_path: (Optional) String value for the location of local certificates. The OPENSSLDIR can be found using the ‘openssl version -a` command then taking OPENSSLDIR and appending ’/certs’. Defaults to the path provided by ‘openssl version -d`.
-
ssl_version: (Optional) String value for the version of SSL to use. By default, this is SSLv23, which creates a TLS/SSL connection which may understand the SSLv3, TLSv1, TLSv1.1 and TLSv1.2 protocols.
Example
client = Arbor::Peakflow::Client.new host: 'http://my.arbor.device/',
api_key: 'myApiKeyHere123',
ssl_verify: false,
ca_path: '/usr/ssl/certs',
ssl_version: 'SSLv23'
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#client ⇒ Object
Returns the value of attribute client.
-
#hosts ⇒ Object
readonly
Returns the value of attribute hosts.
Instance Method Summary collapse
-
#initialize(arguments = {}) ⇒ Client
constructor
A new instance of Client.
- #ssl(arguments) ⇒ Object
- #url_action_filter_request(url, action, filter) ⇒ Object
- #url_filter_limit_format_request(url, filter, limit, format) ⇒ Object
Methods included from Traffic
#remove_returns_and_spaces, #traffic
Methods included from TMS_Ports
Methods included from TMS_Appliance
Methods included from Routers
Methods included from Reports
#configured_reports, #download_report, #queue_report, #report_results
Methods included from Mitigations
Methods included from Managed_Object
Methods included from CP5500
Methods included from Alerts
Constructor Details
#initialize(arguments = {}) ⇒ Client
Returns a new instance of Client.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/arbor_peakflow_ruby/client.rb', line 46 def initialize(arguments = {}) @hosts = arguments[:hosts] || \ arguments[:host] || \ arguments[:url] || \ arguments[:urls] || \ ENV.fetch('PEAKFLOW_URL') @api_key ||= arguments[:api_key] @client = Hurley::Client.new @hosts ssl(arguments) end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
45 46 47 |
# File 'lib/arbor_peakflow_ruby/client.rb', line 45 def api_key @api_key end |
#client ⇒ Object
Returns the value of attribute client.
44 45 46 |
# File 'lib/arbor_peakflow_ruby/client.rb', line 44 def client @client end |
#hosts ⇒ Object (readonly)
Returns the value of attribute hosts.
45 46 47 |
# File 'lib/arbor_peakflow_ruby/client.rb', line 45 def hosts @hosts end |
Instance Method Details
#ssl(arguments) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/arbor_peakflow_ruby/client.rb', line 59 def ssl(arguments) @ssl_verify = arguments[:ssl_verify] || \ false @ca_path = arguments[:ca_path] || \ `openssl version -d`.split(/"/)[1] + '/certs' @ssl_version = arguments[:ssl_version] || \ 'SSLv23' @client..skip_verification = !@ssl_verify @client..ca_path = @ca_path @client..version = @ssl_version end |
#url_action_filter_request(url, action, filter) ⇒ Object
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/arbor_peakflow_ruby/client.rb', line 88 def url_action_filter_request(url, action, filter) response = @client.get(url, {}.tap do |hash| hash[:api_key] = @api_key hash[:action] = action unless action.nil? hash[:filter] = filter unless filter.nil? end) response end |
#url_filter_limit_format_request(url, filter, limit, format) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/arbor_peakflow_ruby/client.rb', line 74 def url_filter_limit_format_request(url, filter, limit, format) response = @client.get(url, {}.tap do |hash| hash[:api_key] = @api_key hash[:format] = format unless format.nil? hash[:limit] = limit unless limit.nil? hash[:filter] = filter unless filter.nil? end) response.body = JSON.parse(response.body) if format == 'json' response end |