arbor_peakflow_ruby 1.1.1 → 1.2.1

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: 95d78faf3486e6b9402aade09389e5ba43dae490
4
- data.tar.gz: 8b7dee7062ac1e31ab864e5051dd12e8f617d976
3
+ metadata.gz: a542c1be96b9dac049ae6efa4ed8b33fbf8f9a21
4
+ data.tar.gz: 6c84cd1841381d0398b5a39ac99b9a6c0ab38c20
5
5
  SHA512:
6
- metadata.gz: e496314be863cb2ff20966765a87eec616971520a426da6ca3bf077c607e186eb7189a1abddb22df172dd2ce51869770a18d1ec81182b877633b2f074e1de735
7
- data.tar.gz: fb981ad00ddd924c1e75315cffdc933bfb7b8fa72aaa3957c0ca4575be663e30c5ac0b381fd7a1d2aa51f66766d72d846b793275e33b499fb2783e989c37d41c
6
+ metadata.gz: cf88c2e684241804d2fc4a9adced818de54703e997558056933d9d305e4929fdaa2ac61e51b6402e92ef3a474712d68bab3c2f96d5060e44aeba1f2f1c852551
7
+ data.tar.gz: d9e3e3a017f2d9a8bccdeaf067073676df8e6cb2c8b85822bdc9f147b0cf6202d5fff97590d56264f974052faf442e3f9c3c81634c2d93effd6888a1f666952e
@@ -4,6 +4,7 @@ rvm:
4
4
  - 2.1.0
5
5
  - 2.1.5
6
6
  - 2.2.0
7
+ - 2.2.1
7
8
 
8
9
  before_install:
9
10
  - gem update --system
data/Gemfile CHANGED
@@ -5,5 +5,5 @@ gemspec
5
5
  gem 'rake', group: :test, require: nil
6
6
  gem 'minitest', group: :test, require: nil
7
7
  gem 'bundler', group: :test, require: nil
8
- gem "codeclimate-test-reporter", group: :test, require: nil
9
- gem 'faraday'
8
+ gem 'codeclimate-test-reporter', group: :test, require: nil
9
+ gem 'hurley'
@@ -10,11 +10,13 @@ module Arbor
10
10
  #
11
11
  # response = client.managed_object 'dorms'
12
12
  def managed_object(filter = nil)
13
- response = @conn.get do |req|
14
- req.url 'arborws/admin/managed_object'
15
- req.params['api_key'] = @api_key
16
- req.params['filter'] = filter unless filter.nil?
17
- end
13
+ response = @client.get('arborws/admin/managed_object',
14
+ {}.tap do |hash|
15
+ hash[:api_key] = @api_key
16
+ hash[:filter] = filter unless filter.nil?
17
+ end)
18
+
19
+ response.body = JSON.parse(response.body)
18
20
 
19
21
  response
20
22
  end
@@ -12,8 +12,8 @@ module Arbor
12
12
  #
13
13
  # response = client.mitigations 'auto-mitigation', 10, 'json'
14
14
  def mitigations(filter = nil, limit = nil, format = 'json')
15
- url_filter_limit_format_request('arborws/mitigations/status', filter,
16
- limit, format)
15
+ url_filter_limit_format_request('arborws/mitigations/status',
16
+ filter, limit, format)
17
17
  end
18
18
  end
19
19
  end
@@ -32,11 +32,8 @@ module Arbor
32
32
  #
33
33
  # response = client.queue_report 'example_report'
34
34
  def queue_report(name)
35
- response = @conn.get do |req|
36
- req.url 'arborws/reports/queue'
37
- req.params['api_key'] = @api_key
38
- req.params['name'] = name
39
- end
35
+ response = @client.get('arborws/reports/queue', api_key: @api_key,
36
+ name: name)
40
37
 
41
38
  response
42
39
  end
@@ -78,13 +75,9 @@ module Arbor
78
75
  #
79
76
  # response = client.download_report 'myReport', 'last', 'PDF'
80
77
  def download_report(name, request_time, format)
81
- response = @conn.get do |req|
82
- req.url 'arborws/reports/configured'
83
- req.params['api_key'] = @api_key
84
- req.params['name'] = name
85
- req.params['request_time'] = request_time
86
- req.params['format'] = format
87
- end
78
+ response = @client.get('arborws/reports/configured',
79
+ api_key: @api_key, name: name,
80
+ request_time: request_time, format: format)
88
81
 
89
82
  response
90
83
  end
@@ -8,10 +8,9 @@ module Arbor
8
8
  #
9
9
  # response = client.tms_ports
10
10
  def tms_ports
11
- response = @conn.get do |req|
12
- req.url 'arborws/admin/tms_ports'
13
- req.params['api_key'] = @api_key
14
- end
11
+ response = @client.get('arborws/admin/tms_ports', api_key: @api_key)
12
+
13
+ response.body = JSON.parse(response.body)
15
14
 
16
15
  response
17
16
  end
@@ -22,12 +22,15 @@ module Arbor
22
22
  # query = File.read('path/to/file.xml')
23
23
  # response = client.traffic query
24
24
  def traffic(query, graph = nil)
25
- response = @conn.get do |req|
26
- req.url 'arborws/traffic'
27
- req.params['api_key'] = @api_key
28
- req.params['query'] = remove_returns_and_spaces(query)
29
- req.params['graph'] = remove_returns_and_spaces(graph) unless graph.nil?
30
- end
25
+ query = remove_returns_and_spaces(query) unless query.nil?
26
+ graph = remove_returns_and_spaces(graph) unless graph.nil?
27
+
28
+ response = @client.get('arborws/traffic',
29
+ {}.tap do |hash|
30
+ hash[:api_key] = @api_key
31
+ hash[:query] = query unless query.nil?
32
+ hash[:graph] = graph unless graph.nil?
33
+ end)
31
34
 
32
35
  response
33
36
  end
@@ -7,13 +7,13 @@ require 'arbor_peakflow_ruby/actions/routers'
7
7
  require 'arbor_peakflow_ruby/actions/tms_appliance'
8
8
  require 'arbor_peakflow_ruby/actions/tms_ports'
9
9
  require 'arbor_peakflow_ruby/actions/traffic'
10
- require 'faraday'
10
+ require 'hurley'
11
11
  require 'json'
12
12
 
13
13
  module Arbor
14
14
  module Peakflow
15
15
  # == Client
16
- # The Arbor Peakflow client in charge of using Faraday to communicate with
16
+ # The Arbor Peakflow client in charge of using Hurley to communicate with
17
17
  # the Arbor devices.
18
18
  #
19
19
  # == Parameters
@@ -41,8 +41,22 @@ module Arbor
41
41
  include Arbor::Peakflow::TMS_Ports
42
42
  include Arbor::Peakflow::Traffic
43
43
 
44
- attr_reader :hosts, :api_key, :conn
44
+ attr_accessor :client
45
+ attr_reader :hosts, :api_key
45
46
  def initialize(arguments = {})
47
+ @hosts = arguments[:hosts] || \
48
+ arguments[:host] || \
49
+ arguments[:url] || \
50
+ arguments[:urls] || \
51
+ ENV.fetch('PEAKFLOW_URL')
52
+
53
+ @api_key ||= arguments[:api_key]
54
+
55
+ @client = Hurley::Client.new @hosts
56
+ ssl(arguments)
57
+ end
58
+
59
+ def ssl(arguments)
46
60
  @ssl_verify = arguments[:ssl_verify] || \
47
61
  false
48
62
 
@@ -52,44 +66,32 @@ module Arbor
52
66
  @ssl_version = arguments[:ssl_version] || \
53
67
  'SSLv23'
54
68
 
55
- @hosts = arguments[:hosts] || \
56
- arguments[:host] || \
57
- arguments[:url] || \
58
- arguments[:urls] || \
59
- ENV.fetch('PEAKFLOW_URL')
60
-
61
- @api_key ||= arguments[:api_key]
62
-
63
- @conn = Faraday.new(@hosts, ssl:
64
- { verify: @ssl_verify,
65
- version: @ssl_version,
66
- ca_path: @ca_path
67
- }) do |faraday|
68
- faraday.request :url_encoded
69
- # faraday.response :logger
70
- faraday.adapter Faraday.default_adapter
71
- end
69
+ @client.ssl_options.skip_verification = !@ssl_verify
70
+ @client.ssl_options.ca_path = @ca_path
71
+ @client.ssl_options.version = @ssl_version
72
72
  end
73
73
 
74
74
  def url_filter_limit_format_request(url, filter, limit, format)
75
- response = @conn.get do |req|
76
- req.url url
77
- req.params['api_key'] = @api_key
78
- req.params['format'] = format
79
- req.params['limit'] = limit unless limit.nil?
80
- req.params['filter'] = filter unless filter.nil?
81
- end
75
+ response = @client.get(url,
76
+ {}.tap do |hash|
77
+ hash[:api_key] = @api_key
78
+ hash[:format] = format unless format.nil?
79
+ hash[:limit] = limit unless limit.nil?
80
+ hash[:filter] = filter unless filter.nil?
81
+ end)
82
+
83
+ response.body = JSON.parse(response.body) if format == 'json'
82
84
 
83
85
  response
84
86
  end
85
87
 
86
88
  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
89
+ response = @client.get(url,
90
+ {}.tap do |hash|
91
+ hash[:api_key] = @api_key
92
+ hash[:action] = action unless action.nil?
93
+ hash[:filter] = filter unless filter.nil?
94
+ end)
93
95
 
94
96
  response
95
97
  end
@@ -1,5 +1,5 @@
1
1
  module Arbor
2
2
  module Peakflow
3
- VERSION = '1.1.1'
3
+ VERSION = '1.2.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arbor_peakflow_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Kirsche