arbor_peakflow_ruby 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 777fcdda62e6c0512f7cc900e1f8122bb6084157
4
- data.tar.gz: f36909933df5b85e3dacec4756e5096deca87499
3
+ metadata.gz: 2af66a1b4a7e7f7e2fc7d966c26489b96cb809f6
4
+ data.tar.gz: 5d8b7703e8ba68a0357d3aca38ef154133248c7d
5
5
  SHA512:
6
- metadata.gz: f7a427aaac57877d7cce0c1ad952941d6f613c0a938c99c4d5acfebca52b8f8478fa9f2789843a232c036ccb1bbf3c77045137ac6a6813d9d8ef6781d188c069
7
- data.tar.gz: 76314ece226a2304594c522968396bf200eb2705d0f6ec4ddc11b8877ecb2b68128a3dfbbdaf3d2b3522c2e7db9aaffdcc1f3259fcc60bc888741b20a853070b
6
+ metadata.gz: 3dbc6560524d434efb5f5250d82069640e2f5e624d38d00ebbe3f1c79155d39912c6805d9c62d6f38dd6e8de857379c8cca5e4fdbfb4b32bdd414b6c7ea0b016
7
+ data.tar.gz: 4b800bb74873d48c48bd69db6e84027b4ad92db06f8b0e86b00503a46dc9e1eabd0b9fa0746112e6e5b6fae2c8aeab667f1ad4c18902036413c86f593cb86e12
@@ -11,14 +11,7 @@ module Arbor
11
11
  #
12
12
  # response = client.cp5500 'show_schema'
13
13
  def cp5500(action, filter = nil)
14
- response = @conn.get do |req|
15
- req.url 'arborws/admin/cp5500'
16
- req.params['api_key'] = @api_key
17
- req.params['action'] = action
18
- req.params['filter'] = filter unless filter.nil?
19
- end
20
-
21
- response
14
+ url_action_filter_request('arborws/admin/cp5500', action, filter)
22
15
  end
23
16
  end
24
17
  end
@@ -15,14 +15,7 @@ module Arbor
15
15
  #
16
16
  # response = client.routers 'show_schema'
17
17
  def routers(action, filter = nil)
18
- response = @conn.get do |req|
19
- req.url 'arborws/admin/routers'
20
- req.params['api_key'] = @api_key
21
- req.params['action'] = action
22
- req.params['filter'] = filter unless filter.nil?
23
- end
24
-
25
- response
18
+ url_action_filter_request('arborws/admin/routers', action, filter)
26
19
  end
27
20
  end
28
21
  end
@@ -15,14 +15,7 @@ module Arbor
15
15
  #
16
16
  # response = client.tms_appliance 'show_schema'
17
17
  def tms_appliance(action, filter = nil)
18
- response = @conn.get do |req|
19
- req.url 'arborws/admin/tms'
20
- req.params['api_key'] = @api_key
21
- req.params['action'] = action
22
- req.params['filter'] = filter unless filter.nil?
23
- end
24
-
25
- response
18
+ url_action_filter_request('arborws/admin/tms', action, filter)
26
19
  end
27
20
  end
28
21
  end
@@ -17,15 +17,19 @@ module Arbor
17
17
  # the Arbor devices.
18
18
  #
19
19
  # == Parameters
20
- # - hosts, host, urls, or url: The location of the Arbor Peakflow
21
- # device cluster
22
- # - api_key: The API key to be used when communicating with the Arbor
23
- # Peakflow API.
20
+ # - hosts, host, urls, or url: The location of the Arbor Peakflow device cluster.
21
+ # - api_key: The API key to be used when communicating with the Arbor Peakflow API.
22
+ # - ssl_verify: (Optional) Boolean value stating whether you would like to verify the SSL certificates. Defaults to false.
23
+ # - 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`.
24
+ # - 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.
24
25
  #
25
26
  # ==== Example
26
27
  #
27
- # client = Arbor::Peaklfow::Client.new host: 'http://my.arbor.device/'
28
- # api_key: 'myApiKeyHere123'
28
+ # client = Arbor::Peakflow::Client.new host: 'http://my.arbor.device/',
29
+ # api_key: 'myApiKeyHere123',
30
+ # ssl_verify: false,
31
+ # ca_path: '/usr/ssl/certs',
32
+ # ssl_version: 'SSLv23'
29
33
  class Client
30
34
  include Arbor::Peakflow::Alerts
31
35
  include Arbor::Peakflow::CP5500
@@ -39,6 +43,15 @@ module Arbor
39
43
 
40
44
  attr_reader :hosts, :api_key, :conn
41
45
  def initialize(arguments = {})
46
+ @ssl_verify = arguments[:ssl_verify] || \
47
+ false
48
+
49
+ @ca_path = arguments[:ca_path] || \
50
+ `openssl version -d`.split(/"/)[1]
51
+
52
+ @ssl_version = arguments[:ssl_version] || \
53
+ 'SSLv23'
54
+
42
55
  @hosts = arguments[:hosts] || \
43
56
  arguments[:host] || \
44
57
  arguments[:url] || \
@@ -47,7 +60,11 @@ module Arbor
47
60
 
48
61
  @api_key ||= arguments[:api_key]
49
62
 
50
- @conn = Faraday.new(@hosts, ssl: { verify: false }) do |faraday|
63
+ @conn = Faraday.new(@hosts, ssl:
64
+ { verify: @ssl_verify,
65
+ version: @ssl_version,
66
+ ca_path: @ca_path
67
+ }) do |faraday|
51
68
  faraday.request :url_encoded
52
69
  # faraday.response :logger
53
70
  faraday.adapter Faraday.default_adapter
@@ -65,6 +82,17 @@ module Arbor
65
82
 
66
83
  response
67
84
  end
85
+
86
+ def url_action_filter_request(url, action, filter)
87
+ response = @conn.get do |req|
88
+ req.url url
89
+ req.params['api_key'] = @api_key
90
+ req.params['action'] = action
91
+ req.params['filter'] = filter unless filter.nil?
92
+ end
93
+
94
+ response
95
+ end
68
96
  end
69
97
  end
70
98
  end
@@ -1,5 +1,5 @@
1
1
  module Arbor
2
2
  module Peakflow
3
- VERSION = '1.0.5'
3
+ VERSION = '1.0.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arbor_peakflow_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Kirsche
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-03-27 00:00:00.000000000 Z
11
+ date: 2015-03-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Provides access to the Arbor Peakflow SP 6.0 HTTPS API
14
14
  email: