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 +4 -4
- data/.travis.yml +1 -0
- data/Gemfile +2 -2
- data/lib/arbor_peakflow_ruby/actions/managed_object.rb +7 -5
- data/lib/arbor_peakflow_ruby/actions/mitigations.rb +2 -2
- data/lib/arbor_peakflow_ruby/actions/reports.rb +5 -12
- data/lib/arbor_peakflow_ruby/actions/tms_ports.rb +3 -4
- data/lib/arbor_peakflow_ruby/actions/traffic.rb +9 -6
- data/lib/arbor_peakflow_ruby/client.rb +35 -33
- data/lib/arbor_peakflow_ruby/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a542c1be96b9dac049ae6efa4ed8b33fbf8f9a21
|
4
|
+
data.tar.gz: 6c84cd1841381d0398b5a39ac99b9a6c0ab38c20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf88c2e684241804d2fc4a9adced818de54703e997558056933d9d305e4929fdaa2ac61e51b6402e92ef3a474712d68bab3c2f96d5060e44aeba1f2f1c852551
|
7
|
+
data.tar.gz: d9e3e3a017f2d9a8bccdeaf067073676df8e6cb2c8b85822bdc9f147b0cf6202d5fff97590d56264f974052faf442e3f9c3c81634c2d93effd6888a1f666952e
|
data/.travis.yml
CHANGED
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
|
9
|
-
gem '
|
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 = @
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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',
|
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 = @
|
36
|
-
|
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 = @
|
82
|
-
|
83
|
-
|
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 = @
|
12
|
-
|
13
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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 '
|
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
|
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
|
-
|
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
|
-
@
|
56
|
-
|
57
|
-
|
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 = @
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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 = @
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
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
|