arbor_peakflow_ruby 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ddba0bf5c2df3bce58c22370c6c300073b9ce406
4
+ data.tar.gz: 9c9c9ddb0d811675b210e2f99888002e7cd772a7
5
+ SHA512:
6
+ metadata.gz: 1f2f82a8a2e47eebea695575382216da5e1cd76caf791ffb44638479b6e36c1c7f7c723370b4997859ce17b080c64732f8c8301b52f6991fdbbde7390764e47f
7
+ data.tar.gz: 6bfd181d47f02216ad1050c95930f185e444ce62f7e6c0a348562fbac5cd7ff09f6fca1f026212ff69cc9d47a34491c61523c3cb4b1415e7584220e8d5eef150
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ test/.DS_Store
11
+ .DS_Store
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.0
5
+ - 2.1.5
6
+ - 2.2.0
7
+
8
+ before_install:
9
+ - gem update --system
10
+ - gem --version
11
+
12
+ gemfile:
13
+ - Gemfile
14
+
15
+ notifications:
16
+ email: false
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in arbor_peakflow_ruby.gemspec
4
+ gemspec
5
+ gem 'rake', group: :test, require: nil
6
+ gem 'minitest', group: :test, require: nil
7
+ gem 'bundler', group: :test, require: nil
8
+ gem 'faraday'
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # ArborPeakflowRuby
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/arbor_peakflow_ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'arbor_peakflow_ruby'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install arbor_peakflow_ruby
22
+
23
+ ## Usage
24
+
25
+ Within your application, create a client. With the client, you can access then all available actions (refer to RDocs for info on these). Each response has a `.body`, `.status`, and `.headers` methods. Status returns the HTTP status code, such as 200. Body returns the response body, and Headers returns the response headers.
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/kkirsche/arbor_peakflow_ruby/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test/"
6
+ t.libs << "bin/"
7
+ t.libs << "lib/"
8
+ t.pattern = "test/arbor_peakflow_ruby/**/*_spec.rb"
9
+ end
10
+
11
+ task :default => :test
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'arbor_peakflow_ruby/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "arbor_peakflow_ruby"
8
+ spec.version = Arbor::Peakflow::VERSION
9
+ spec.authors = ["Kevin Kirsche"]
10
+ spec.email = ["kevin.kirsche@verizon.com"]
11
+
12
+ spec.summary = %q{Arbor Peakflow 6.0 API interaction gem}
13
+ spec.description = %q{Provides access to the Arbor Peakflow SP 6.0 HTTPS API}
14
+ spec.homepage = "https://github.com/kkirsche/arbor-peakflow-ruby"
15
+ spec.license = "MIT"
16
+
17
+ spec.required_ruby_version = '>= 2.0.0'
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "arbor_peakflow_ruby"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,32 @@
1
+ module Arbor
2
+ module Peakflow
3
+ module Alerts
4
+ # The alerts function allows you to search for and retrieve JSON or XML
5
+ # alert information.
6
+ #
7
+ # == Parameters:
8
+ # - filter: (Optional) Keywords by which you want to filter search
9
+ # results. You can enter the same search strings that you can enter in
10
+ # the Search box on the Alerts pages in the Web UI.
11
+ # - limit: (Optional) The maximum number of alerts to return that match
12
+ # the filter.
13
+ # - format: The format in which you want the data returned:
14
+ # 'json' or 'xml'
15
+ #
16
+ # ==== Example
17
+ #
18
+ # response = client.alerts 'host', 100, 'json'
19
+ def alerts(filter = nil, limit = nil, format = 'json')
20
+ response = @conn.get do |req|
21
+ req.url 'arborws/alerts'
22
+ req.params['api_key'] = @api_key
23
+ req.params['format'] = format
24
+ req.params['filter'] = filter unless filter.nil?
25
+ req.params['limit'] = limit unless limit.nil?
26
+ end
27
+
28
+ response
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,31 @@
1
+ module Arbor
2
+ module Peakflow
3
+ module CP5500
4
+ # The CP 5500 function allows you to view CP 5500 appliance configurations
5
+ # in JSON format. *Note:* This function is only available with
6
+ # appliance-based licensing for Traffic and Analysis Routing appliances
7
+ # (formally Collector Platform (CP) appliances).
8
+ #
9
+ # == Parameters:
10
+ # - action: One of the following actions that you want to initiate:
11
+ # list, show_schema, update.
12
+ # - filter: (Optional) Keywords by which you want to filter search
13
+ # results. You can enter the same search strings that you can enter in
14
+ # the Search box on the Configure Routers page in the Web UI.
15
+ #
16
+ # ==== Example
17
+ #
18
+ # response = client.cp5500 'show_schema'
19
+ def cp5500(action, filter = nil)
20
+ response = @conn.get do |req|
21
+ req.url 'arborws/admin/cp5500'
22
+ req.params['api_key'] = @api_key
23
+ req.params['action'] = action
24
+ req.params['filter'] = filter unless filter.nil?
25
+ end
26
+
27
+ response
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,26 @@
1
+ module Arbor
2
+ module Peakflow
3
+ module Managed_Object
4
+ # The managed object function allows you to view managed object
5
+ # configuration data in JSON format.
6
+ #
7
+ # == Parameters:
8
+ # - filter: (Optional) Keywords by which you want to filter search
9
+ # results. You can enter the same search strings that you can enter in
10
+ # the Search box on the Managed Objects pages in the Web UI.
11
+ #
12
+ # ==== Example
13
+ #
14
+ # response = client.managed_object 'dorms'
15
+ def managed_object(filter = nil)
16
+ response = @conn.get do |req|
17
+ req.url 'arborws/admin/managed_object'
18
+ req.params['api_key'] = @api_key
19
+ req.params['filter'] = filter unless filter.nil?
20
+ end
21
+
22
+ response
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ module Arbor
2
+ module Peakflow
3
+ module Mitigations
4
+ # The mitigations function allows you to search for and retrieve JSON and
5
+ # XML mitigation information.
6
+ #
7
+ # == Parameters:
8
+ # - filter: (Optional) Keywords by which you want to filter search
9
+ # results. You can enter the same search strings that you can enter in
10
+ # the Search box on the Mitigations pages in the Web UI.
11
+ # - limit: (Optional) The maximum number of mitigations to return that
12
+ # match the filter.
13
+ # - format: The format in which you want the data returned:
14
+ # 'json' or 'xml'
15
+ #
16
+ # ==== Example
17
+ #
18
+ # response = client.mitigations 'auto-mitigation', 10, 'json'
19
+ def mitigations(filter = nil, limit = nil, format = 'json')
20
+ response = @conn.get do |req|
21
+ req.url 'arborws/mitigations/status'
22
+ req.params['api_key'] = @api_key
23
+ req.params['format'] = format
24
+ req.params['filter'] = filter unless filter.nil?
25
+ req.params['limit'] = limit unless limit.nil?
26
+ end
27
+
28
+ response
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,107 @@
1
+ module Arbor
2
+ module Peakflow
3
+ module Reports
4
+ # Allows you to view a list of the configured wizard reports in Peakflow
5
+ # SP
6
+ #
7
+ # == Parameters:
8
+ # - filter: (Optional) Keywords by which you want to filter search
9
+ # results. You can enter the same search strings that you can enter in
10
+ # the Search box on the Alerts pages in the Web UI.
11
+ # - limit: (Optional) The maximum number of alerts to return that match
12
+ # the filter.
13
+ # - format: The format in which you want the data returned:
14
+ # 'json' or 'xml'
15
+ #
16
+ # ==== Example
17
+ #
18
+ # response = client.configured_reports
19
+ def configured_reports(filter = nil, limit = nil, format = 'json')
20
+ response = @conn.get do |req|
21
+ req.url 'arborws/reports/configured'
22
+ req.params['api_key'] = @api_key
23
+ req.params['format'] = format
24
+ req.params['filter'] = filter unless filter.nil?
25
+ req.params['limit'] = limit unless limit.nil?
26
+ end
27
+
28
+ response
29
+ end
30
+
31
+ # Allows you to queue a wizard report to run
32
+ #
33
+ # == Parameters:
34
+ # - name: The name of the configured wizard report that you want to run.
35
+ # The returned value is one of the following: an HTTP status code 204,
36
+ # which indicates success or an error message.
37
+ #
38
+ # ==== Example
39
+ #
40
+ # response = client.queue_report 'example_report'
41
+ def queue_report(name)
42
+ response = @conn.get do |req|
43
+ req.url 'arborws/reports/queue'
44
+ req.params['api_key'] = @api_key
45
+ req.params['name'] = name
46
+ end
47
+
48
+ response
49
+ end
50
+
51
+ # Allows you to view a list of wizard report results that can be
52
+ # downloaded from Peakflow SP.
53
+ #
54
+ # == Parameters:
55
+ # - filter: (Optional) Keywords by which you want to filter search
56
+ # results. You can enter the same search strings that you can enter in
57
+ # the Search box on the Alerts pages in the Web UI.
58
+ # - limit: (Optional) The maximum number of alerts to return that match
59
+ # the filter.
60
+ # - format: The format in which you want the data returned:
61
+ # 'json' or 'xml'
62
+ #
63
+ # ==== Example
64
+ #
65
+ # response = client.report_results
66
+ def report_results(filter = nil, limit = nil, format = 'json')
67
+ response = @conn.get do |req|
68
+ req.url 'arborws/reports/results'
69
+ req.params['api_key'] = @api_key
70
+ req.params['format'] = format
71
+ req.params['filter'] = filter unless filter.nil?
72
+ req.params['limit'] = limit unless limit.nil?
73
+ end
74
+
75
+ response
76
+ end
77
+
78
+ # Allows you to download a completed wizard report.
79
+ #
80
+ # == Parameters:
81
+ # - name: The name of the configured wizard report result that you want
82
+ # to download.
83
+ # - request_time: The time of the wizard report result that you want to
84
+ # download, which can be one of the following: last (The "last" parameter
85
+ # downloads the most recent wizard report result), time (the "time"
86
+ # parameter is the time at which a wizard report ran, in seconds and
87
+ # microseconds since the epoch.)
88
+ # - format: The format in which you want a wizard report returned, which
89
+ # can be one of the following: "PDF", "XML", "CSV".
90
+ #
91
+ # ==== Example
92
+ #
93
+ # response = client.download_report 'myReport', 'last', 'PDF'
94
+ def download_report(name, request_time, format)
95
+ response = @conn.get do |req|
96
+ req.url 'arborws/reports/configured'
97
+ req.params['api_key'] = @api_key
98
+ req.params['name'] = name
99
+ req.params['request_time'] = request_time
100
+ req.params['format'] = format
101
+ end
102
+
103
+ response
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,29 @@
1
+ module Arbor
2
+ module Peakflow
3
+ module Routers
4
+ # The routers function allow syou to view router configuration in JSON
5
+ # format.
6
+ #
7
+ # == Parameters:
8
+ # - action: One of the following actions that you want to initiate:
9
+ # list, show_schema, update.
10
+ # - filter: (Optional) Keywords by which you want to filter search
11
+ # results. You can enter the same search strings that you can enter in
12
+ # the Search box on the Configure Routers page in the Web UI.
13
+ #
14
+ # ==== Example
15
+ #
16
+ # response = client.routers 'show_schema'
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
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ module Arbor
2
+ module Peakflow
3
+ module TMS_Appliance
4
+ # The TMS function allows you to view and update TMS appliance
5
+ # configurations in JSON format.
6
+ #
7
+ # == Parameters:
8
+ # - action: One of the following actions that you want to initiate:
9
+ # list, show_schema, update.
10
+ # - filter: (Optional) Keywords by which you want to filter search
11
+ # results. You can enter the same search strings that you can enter in
12
+ # the Search box on the Configure Routers page in the Web UI.
13
+ #
14
+ # ==== Example
15
+ #
16
+ # response = client.tms_appliance 'show_schema'
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
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ module Arbor
2
+ module Peakflow
3
+ module TMS_Ports
4
+ # The TMS Ports function allows you to view TMS appliance port data in
5
+ # JSON format.
6
+ #
7
+ # ==== Example
8
+ #
9
+ # response = client.tms_ports
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
15
+
16
+ response
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,30 @@
1
+ module Arbor
2
+ module Peakflow
3
+ module Traffic
4
+ # The traffic function allows you to search for and retrieve XML traffic
5
+ # data.
6
+ #
7
+ # == Parameters:
8
+ # - query: An XML query in standard Peakflow SP XML query format. This
9
+ # parameter is only the XML query, not an entire XML report. Data is
10
+ # returned in the XML result format, as specified in the _Peakflow SP and
11
+ # Threat Management System (TMS) User Guide_. For current report
12
+ # specifications, see "Using Cusomized Reports" in the _Peakflow SP and
13
+ # Threat Management System (TMS) User Guide_.
14
+ # - graph: (Optional) When specified, this parameter indicates that you
15
+ # want Peakflow SP to return a binary PNG graph file of the queried
16
+ # traffic data. If you do not specify a graph argument, then Peakflow SP
17
+ # returns XML.
18
+ def traffic(query, graph = nil)
19
+ response = @conn.get do |req|
20
+ req.url 'arborws/traffic'
21
+ req.params['api_key'] = @api_key
22
+ req.params['query'] = query
23
+ req.params['graph'] = graph unless graph.nil?
24
+ end
25
+
26
+ response
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,58 @@
1
+ require 'arbor_peakflow_ruby/actions/alerts'
2
+ require 'arbor_peakflow_ruby/actions/cp5500'
3
+ require 'arbor_peakflow_ruby/actions/managed_object'
4
+ require 'arbor_peakflow_ruby/actions/mitigations'
5
+ require 'arbor_peakflow_ruby/actions/reports'
6
+ require 'arbor_peakflow_ruby/actions/routers'
7
+ require 'arbor_peakflow_ruby/actions/tms_appliance'
8
+ require 'arbor_peakflow_ruby/actions/tms_ports'
9
+ require 'arbor_peakflow_ruby/actions/traffic'
10
+ require 'faraday'
11
+ require 'json'
12
+
13
+ module Arbor
14
+ module Peakflow
15
+ # == Client
16
+ # The Arbor Peakflow client in charge of using Faraday to communicate with
17
+ # the Arbor devices.
18
+ #
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.
24
+ #
25
+ # ==== Example
26
+ #
27
+ # client = Arbor::Peaklfow::Client.new host: 'http://my.arbor.device/'
28
+ # api_key: 'myApiKeyHere123'
29
+ class Client
30
+ include Arbor::Peakflow::Alerts
31
+ include Arbor::Peakflow::CP5500
32
+ include Arbor::Peakflow::Managed_Object
33
+ include Arbor::Peakflow::Mitigations
34
+ include Arbor::Peakflow::Reports
35
+ include Arbor::Peakflow::Routers
36
+ include Arbor::Peakflow::TMS_Appliance
37
+ include Arbor::Peakflow::TMS_Ports
38
+ include Arbor::Peakflow::Traffic
39
+
40
+ attr_reader :hosts, :api_key
41
+ def initialize(arguments = {})
42
+ @hosts = arguments[:hosts] || \
43
+ arguments[:host] || \
44
+ arguments[:url] || \
45
+ arguments[:urls] || \
46
+ ENV.fetch('PEAKFLOW_URL')
47
+
48
+ @api_key ||= arguments[:api_key]
49
+
50
+ @conn = Faraday.new(@hosts, ssl: { verify: false }) do |faraday|
51
+ faraday.request :url_encoded
52
+ # faraday.response :logger
53
+ faraday.adapter Faraday.default_adapter
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,5 @@
1
+ module Arbor
2
+ module Peakflow
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'arbor_peakflow_ruby/version'
2
+ require 'arbor_peakflow_ruby/client'
3
+
4
+ module Arbor
5
+ module Peakflow
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: arbor_peakflow_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Kirsche
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-03-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Provides access to the Arbor Peakflow SP 6.0 HTTPS API
14
+ email:
15
+ - kevin.kirsche@verizon.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".travis.yml"
22
+ - Gemfile
23
+ - README.md
24
+ - Rakefile
25
+ - arbor_peakflow_ruby.gemspec
26
+ - bin/console
27
+ - bin/setup
28
+ - lib/arbor_peakflow_ruby.rb
29
+ - lib/arbor_peakflow_ruby/actions/alerts.rb
30
+ - lib/arbor_peakflow_ruby/actions/cp5500.rb
31
+ - lib/arbor_peakflow_ruby/actions/managed_object.rb
32
+ - lib/arbor_peakflow_ruby/actions/mitigations.rb
33
+ - lib/arbor_peakflow_ruby/actions/reports.rb
34
+ - lib/arbor_peakflow_ruby/actions/routers.rb
35
+ - lib/arbor_peakflow_ruby/actions/tms_appliance.rb
36
+ - lib/arbor_peakflow_ruby/actions/tms_ports.rb
37
+ - lib/arbor_peakflow_ruby/actions/traffic.rb
38
+ - lib/arbor_peakflow_ruby/client.rb
39
+ - lib/arbor_peakflow_ruby/version.rb
40
+ homepage: https://github.com/kkirsche/arbor-peakflow-ruby
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.0.0
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.4.3
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Arbor Peakflow 6.0 API interaction gem
64
+ test_files: []