isepick 0.1.1

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
+ SHA256:
3
+ metadata.gz: ef47d75196d958f77e4a82dd152dabf61962a0e0ebfc4eff407ecb5f4b19a30a
4
+ data.tar.gz: e279324f04507274a9dcf0e91f7b06c62d399ae0e9a38ea1445a082c7c5c5bfe
5
+ SHA512:
6
+ metadata.gz: 02461a10047546c8f41e91e4db1e3755f227b9617b9d5b0e918ca4574b004d1213b985401b0aad48c0493b9a50580fff28a98987e00e79014887f0ef1899a2c7
7
+ data.tar.gz: 9c8eb949656b665b8a9e6d85298e61f3c70cc60284d5e680417d34693b587f9084d08a5c9868a266590f17c993609ff89ae5a87963f3e0455ad77dd48d40c6a7
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 2.0.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in isepick.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,58 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ isepick (0.1.0)
5
+ activesupport (~> 6.0.0)
6
+ faraday (~> 0.17)
7
+ nokogiri (~> 1.10)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (6.0.0)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 0.7, < 2)
15
+ minitest (~> 5.1)
16
+ tzinfo (~> 1.1)
17
+ zeitwerk (~> 2.1, >= 2.1.8)
18
+ concurrent-ruby (1.1.5)
19
+ diff-lcs (1.3)
20
+ faraday (0.17.0)
21
+ multipart-post (>= 1.2, < 3)
22
+ i18n (1.7.0)
23
+ concurrent-ruby (~> 1.0)
24
+ mini_portile2 (2.4.0)
25
+ minitest (5.12.2)
26
+ multipart-post (2.1.1)
27
+ nokogiri (1.10.4)
28
+ mini_portile2 (~> 2.4.0)
29
+ rake (10.5.0)
30
+ rspec (3.9.0)
31
+ rspec-core (~> 3.9.0)
32
+ rspec-expectations (~> 3.9.0)
33
+ rspec-mocks (~> 3.9.0)
34
+ rspec-core (3.9.0)
35
+ rspec-support (~> 3.9.0)
36
+ rspec-expectations (3.9.0)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.9.0)
39
+ rspec-mocks (3.9.0)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.9.0)
42
+ rspec-support (3.9.0)
43
+ thread_safe (0.3.6)
44
+ tzinfo (1.2.5)
45
+ thread_safe (~> 0.1)
46
+ zeitwerk (2.2.0)
47
+
48
+ PLATFORMS
49
+ ruby
50
+
51
+ DEPENDENCIES
52
+ bundler (~> 2.0)
53
+ isepick!
54
+ rake (~> 10.0)
55
+ rspec (~> 3.0)
56
+
57
+ BUNDLED WITH
58
+ 2.0.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Abhi Devireddy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Isepick
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/isepick`. 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 'isepick'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install isepick
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also 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`, which will 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
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/isepick.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "isepick"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/isepick.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "isepick/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "isepick"
7
+ spec.version = Isepick::VERSION
8
+ spec.authors = ["Abhi Devireddy"]
9
+ spec.email = ["abhi@devireddy.com"]
10
+
11
+ spec.summary = "Cisco ISE 2.4 API Client - ERS and Monitoring"
12
+ spec.description = "Cisco ISE 2.4 API Client - ERS and Monitoring"
13
+ spec.homepage = "https://github.com/abhid/isepick"
14
+ spec.license = "MIT"
15
+
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/abhid/isepick"
20
+ spec.metadata["changelog_uri"] = "https://github.com/abhid/isepick"
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 2.0"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+ spec.add_dependency "faraday", "~> 0.17"
35
+ spec.add_dependency "nokogiri", "~> 1.10"
36
+ spec.add_dependency "activesupport", "~> 6.0.0"
37
+ end
data/lib/isepick.rb ADDED
@@ -0,0 +1,179 @@
1
+ require "isepick/version"
2
+ require "faraday"
3
+ require "nokogiri"
4
+ require "json"
5
+ require 'active_support/core_ext/hash'
6
+
7
+ module Isepick
8
+ class IseMNT
9
+ def initialize(mnt_host, mnt_user, mnt_password)
10
+ @client = Faraday.new("https://#{mnt_host}/admin/API/mnt/") do |conn|
11
+ conn.basic_auth(mnt_user, mnt_password)
12
+ conn.adapter Faraday.default_adapter
13
+ conn.ssl[:verify] = false
14
+ conn.headers["Accept"] = "application/xml"
15
+ end
16
+ end
17
+
18
+ def activeSessions(pageSize = 25, page = 1)
19
+ session_xml = Nokogiri::XML(@client.get("Session/ActiveList", {pageSize: pageSize, page: page}).body)
20
+ return Hash.from_xml(session_xml.to_s)
21
+ end
22
+
23
+ def session_filterByMAC(mac_addr)
24
+ filter_param = mac_addr.gsub(/[^a-fA-F0-9]/, "").upcase.gsub(/(.{2})(?=.)/, '\1:\2')
25
+ session_xml = Nokogiri::XML(@client.get("Session/MACAddress/#{filter_param}").body)
26
+ return Hash.from_xml(session_xml.to_s)
27
+ end
28
+
29
+ def session_filterByIP(ip_addr)
30
+ session_xml = Nokogiri::XML(@client.get("Session/EndPointIPAddress/#{ip_addr}").body)
31
+ return Hash.from_xml(session_xml.to_s)
32
+ end
33
+ end
34
+
35
+ class IseERS
36
+ def initialize(psn_host, psn_user, psn_password)
37
+ @client = Faraday.new("https://#{psn_host}:9060/ers/config/") do |conn|
38
+ conn.basic_auth(psn_user, psn_password)
39
+ conn.adapter Faraday.default_adapter
40
+ conn.ssl[:verify] = false
41
+ conn.headers["Accept"] = "application/json"
42
+ end
43
+ end
44
+ # Endpoints
45
+ def ep_getAll(pageSize = 25, page = 1)
46
+ return JSON.parse(@client.get("endpoint").body)
47
+ end
48
+
49
+ def ep_get(ep_id)
50
+ return JSON.parse(@client.get("endpoint/#{ep_id}").body)
51
+ end
52
+
53
+ def ep_filterByMAC(mac_addr)
54
+ filter_param = mac_addr.gsub(/[^a-fA-F0-9]/, "").upcase.gsub(/(.{2})(?=.)/, '\1:\2')
55
+ return JSON.parse(@client.get("endpoint?filter=mac.EQ.#{filter_param}").body)
56
+ end
57
+
58
+ # Network Device Group
59
+ def ndg_getAll()
60
+ current_page = 1
61
+ output = []
62
+
63
+ loop do
64
+ cur_output = JSON.parse(@client.get("networkdevicegroup?size=25&page=#{current_page}").body)
65
+ output += cur_output["SearchResult"]["resources"]
66
+ if cur_output["SearchResult"].key?("nextPage")
67
+ current_page += 1
68
+ else
69
+ break
70
+ end
71
+ end
72
+ return output
73
+ end
74
+
75
+ def ndg_get(ndg_id)
76
+ return JSON.parse(@client.get("networkdevicegroup/#{ndg_id}").body)
77
+ end
78
+
79
+ # Network Device
80
+ def nd_getAll()
81
+ current_page = 1
82
+ output = []
83
+
84
+ loop do
85
+ cur_output = JSON.parse(@client.get("networkdevice?size=25&page=#{current_page}").body)
86
+ output += cur_output["SearchResult"]["resources"]
87
+ if cur_output["SearchResult"].key?("nextPage")
88
+ current_page += 1
89
+ else
90
+ break
91
+ end
92
+ end
93
+ return output
94
+ end
95
+
96
+ def nd_get(nd_id)
97
+ return JSON.parse(@client.get("networkdevice/#{nd_id}").body)
98
+ end
99
+
100
+ # Endpoint Identity Group
101
+ def eig_getAll()
102
+ current_page = 1
103
+ output = []
104
+
105
+ loop do
106
+ cur_output = JSON.parse(@client.get("endpointgroup?size=25&page=#{current_page}").body)
107
+ output += cur_output["SearchResult"]["resources"]
108
+ if cur_output["SearchResult"].key?("nextPage")
109
+ current_page += 1
110
+ else
111
+ break
112
+ end
113
+ end
114
+ return output
115
+ end
116
+
117
+ def eig_get(eig_id)
118
+ return JSON.parse(@client.get("endpointgroup/#{eig_id}").body)
119
+ end
120
+
121
+ def eig_getEndpoints(eig_id)
122
+ current_page = 1
123
+ output = []
124
+
125
+ loop do
126
+ cur_output = JSON.parse(@client.get("endpoint?size=25&page=#{current_page}&filter=groupId.EQ.#{eig_id}").body)
127
+ output += cur_output["SearchResult"]["resources"]
128
+ if cur_output["SearchResult"].key?("nextPage")
129
+ current_page += 1
130
+ else
131
+ break
132
+ end
133
+ end
134
+ return output
135
+ end
136
+
137
+ # Downloadable ACL
138
+ def dacl_getAll()
139
+ current_page = 1
140
+ output = []
141
+
142
+ loop do
143
+ cur_output = JSON.parse(@client.get("downloadableacl?size=25&page=#{current_page}").body)
144
+ output += cur_output["SearchResult"]["resources"]
145
+ if cur_output["SearchResult"].key?("nextPage")
146
+ current_page += 1
147
+ else
148
+ break
149
+ end
150
+ end
151
+ return output
152
+ end
153
+
154
+ def dacl_get(uuid)
155
+ return JSON.parse(@client.get("downloadableacl/#{uuid}").body)
156
+ end
157
+
158
+ # Authorization Profile
159
+ def aznprofile_getAll()
160
+ current_page = 1
161
+ output = []
162
+
163
+ loop do
164
+ cur_output = JSON.parse(@client.get("authorizationprofile?size=25&page=#{current_page}").body)
165
+ output += cur_output["SearchResult"]["resources"]
166
+ if cur_output["SearchResult"].key?("nextPage")
167
+ current_page += 1
168
+ else
169
+ break
170
+ end
171
+ end
172
+ return output
173
+ end
174
+
175
+ def aznprofile_get(uuid)
176
+ return JSON.parse(@client.get("authorizationprofile/#{uuid}").body)
177
+ end
178
+ end
179
+ end
@@ -0,0 +1,3 @@
1
+ module Isepick
2
+ VERSION = "0.1.1"
3
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: isepick
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Abhi Devireddy
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-11-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.17'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.17'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.10'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activesupport
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 6.0.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 6.0.0
97
+ description: Cisco ISE 2.4 API Client - ERS and Monitoring
98
+ email:
99
+ - abhi@devireddy.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - Gemfile.lock
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - bin/console
113
+ - bin/setup
114
+ - isepick.gemspec
115
+ - lib/isepick.rb
116
+ - lib/isepick/version.rb
117
+ homepage: https://github.com/abhid/isepick
118
+ licenses:
119
+ - MIT
120
+ metadata:
121
+ allowed_push_host: https://rubygems.org
122
+ homepage_uri: https://github.com/abhid/isepick
123
+ source_code_uri: https://github.com/abhid/isepick
124
+ changelog_uri: https://github.com/abhid/isepick
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubygems_version: 3.0.3
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: Cisco ISE 2.4 API Client - ERS and Monitoring
144
+ test_files: []