junos-space-api 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -24,7 +24,8 @@ Here are the current web services available so far in this API:
24
24
  - Service Management
25
25
  - Device Management
26
26
 
27
- Please see [Juniper's documentation][2] for the full release notes on the Security Director API.
27
+ Please see Juniper's documentation for the full release notes on the [Junos Space API][5], as well as
28
+ the [Security Director API][2].
28
29
 
29
30
  I will be adding more functionality/web services soon, so please keep checking back!
30
31
 
@@ -45,4 +46,5 @@ to [Juniper Networks][4] for creating such great products :)
45
46
  [1]: https://github.com/scottdware/junos-ruby-space-api/wiki
46
47
  [2]: http://www.juniper.net/techpubs/en_US/junos-space13.1/information-products/topic-collections/junos-space-security-designer/security-director-api.pdf
47
48
  [3]: https://github.com/jeremyschulman
48
- [4]: http://www.juniper.net
49
+ [4]: http://www.juniper.net
50
+ [5]: https://developer.juniper.net/shared/jdn/html/browserhelp/index.htm
Binary file
@@ -3,7 +3,7 @@ require 'rake'
3
3
  Gem::Specification.new do |s|
4
4
  s.license = 'MIT'
5
5
  s.name = 'junos-space-api'
6
- s.version = '0.2.1'
6
+ s.version = '0.2.2'
7
7
  s.summary = 'Interact with the Junos Space REST API.'
8
8
  s.description = 'This gem is used to interact with Juniper Networks Junos Space management platform using the REST API.'
9
9
  s.authors = ["Scott Ware"]
@@ -1,2 +1,3 @@
1
1
  require 'junos-space-api/platform/job'
2
- require 'junos-space-api/platform/device'
2
+ require 'junos-space-api/platform/device'
3
+ require 'junos-space-api/platform/audit'
@@ -0,0 +1,63 @@
1
+ require 'rest-client'
2
+ require 'nokogiri'
3
+ require 'junos-space-api/space'
4
+
5
+ class JunosSpace::Platform::AuditLog
6
+ @@audit_uri = '/api/space/audit-log-management/audit-logs'
7
+
8
+ # list
9
+ #
10
+ # Returns an array of all of the audit logs in Space.
11
+ #
12
+ def list
13
+ result = []
14
+
15
+ begin
16
+ res = RestClient.get("#{JunosSpace.base_uri}#{@@audit_uri}")
17
+ doc = Nokogiri::XML::Document.parse(res)
18
+
19
+ doc.xpath('//audit-log').each do |log|
20
+ id = log.xpath('@key').text
21
+
22
+ result << id
23
+ end
24
+
25
+ return result
26
+ rescue RestClient::Unauthorized
27
+ result['status'] = '401 Error - Auth failure (bad username/password).'
28
+
29
+ return result
30
+ end
31
+ end
32
+
33
+ # info(log)
34
+ #
35
+ # Returns information about the audit log 'id'. This information is
36
+ # returned in a Hash with the log ID, user, IP address, description, time,
37
+ # task name, and result.
38
+ #
39
+ def info(id)
40
+ result = {}
41
+
42
+ begin
43
+ res = RestClient.get("#{JunosSpace.base_uri}#{@@audit_uri}/#{id}")
44
+ doc = Nokogiri::XML::Document.parse(res)
45
+
46
+ doc.xpath('//audit-log').each do |log|
47
+ result["id"] = id
48
+ result["user"] = log.xpath('userName').text
49
+ result["ip"] = log.xpath('userIpAddr').text
50
+ result["description"] = log.xpath('description').text
51
+ result["time"] = log.xpath('logTime').text
52
+ result["task"] = log.xpath('taskName').text
53
+ result["result"] = log.xpath('result').text
54
+ end
55
+
56
+ return result
57
+ rescue RestClient::Unauthorized
58
+ result['status'] = '401 Error - Auth failure (bad username/password).'
59
+
60
+ return result
61
+ end
62
+ end
63
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: junos-space-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -18,10 +18,11 @@ executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
- - junos-space-api-0.2.0.gem
21
+ - junos-space-api-0.2.1.gem
22
22
  - junos-space-api.gemspec
23
23
  - LICENSE
24
24
  - README.md
25
+ - lib/junos-space-api/platform/audit.rb
25
26
  - lib/junos-space-api/platform/device.rb
26
27
  - lib/junos-space-api/platform/job.rb
27
28
  - lib/junos-space-api/platform.rb
Binary file