ruby-paloalto-client 0.0.6 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e02a369bdffd33aae3c9e09ed5c7c12144085507
4
- data.tar.gz: ef555e5807be0c37aff0141bbf8b9ad0543d83a1
3
+ metadata.gz: 17a2840f834cb5377d8a8b63cb21c4b6cd28afeb
4
+ data.tar.gz: a76992e8ba1c4931c0fe9dcc86986c334e052222
5
5
  SHA512:
6
- metadata.gz: 5813efa8c094d8f3e5f3f84ed002163bffa23b57b3ac594560875ad5fe2678895ad5289049754de220855b3e7d07c19f6ee515f2dd8e76cb074f496d8e5e5b54
7
- data.tar.gz: ee5e1550103d91610627bd32e7e8cd8c139e8731af6e91b4d6927b015fe4a5b29d02e223b2def1acc5fe426d3da71e39dbe74288f274cb42248314d2832db9a3
6
+ metadata.gz: 36ce78b3ac071f0296750d4c9cc24fd6455a36fc5505896a0375f14529c3b26d4631fa545b3c2bf88eb86dcf31f4591a546de8873ff3bfb34022af76e48aedec
7
+ data.tar.gz: ec5fb27f26375f00fda3d9cb708dd356922c83f2d19ca83611dd2396e6119fe0d90df3be9b482d19f70d9f215e350c6249a75ee26ff50763bbfdf571b0f84aa1
@@ -1,5 +1,5 @@
1
1
  module PaloAlto
2
2
  module Client
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
@@ -6,6 +6,7 @@ require "palo_alto/v6/log_api"
6
6
  require "palo_alto/v6/security_rule_api"
7
7
  require "palo_alto/v6/commit_api"
8
8
  require "palo_alto/v6/zone_api"
9
+ require "palo_alto/v6/job_api"
9
10
 
10
11
  module PaloAlto
11
12
  module V6
@@ -19,6 +20,7 @@ module PaloAlto
19
20
  include PaloAlto::V6::SecurityRuleApi
20
21
  include PaloAlto::V6::CommitApi
21
22
  include PaloAlto::V6::ZoneApi
23
+ include PaloAlto::V6::JobApi
22
24
  end
23
25
  end
24
26
  end
@@ -0,0 +1,38 @@
1
+ require "crack/xml"
2
+
3
+ module PaloAlto
4
+ module V6
5
+ module JobApi
6
+ # Get information about a particular operational
7
+ #
8
+ # == Parameters
9
+ #
10
+ # * +job_id+ - ID of the job to query for
11
+ #
12
+ # == Returns
13
+ #
14
+ # * +JSON+ - JSON data containing the job ID and corresponding status
15
+ #
16
+ # == Raises
17
+ #
18
+ # * +Exception+ - Raises an exception if the request is unsuccessful
19
+ def operational_job(job_id:)
20
+ job_json = { id: job_id }
21
+
22
+ # configure options for the request
23
+ options = {}
24
+ options[:url] = self.endpoint
25
+ options[:method] = :post
26
+ options[:payload] = { :type => "op",
27
+ :cmd => "<show><jobs><id>#{job_id}</id></jobs></show>",
28
+ :key => self.auth_key }
29
+
30
+ html_result = Helpers::Rest.make_request(options)
31
+
32
+ raise "Error obtaining log job XML" if html_result.nil?
33
+
34
+ return Crack::XML.parse(html_result)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,19 @@
1
+ <response status="success">
2
+ <result>
3
+ <job>
4
+ <tenq>2015/07/27 11:13:31</tenq>
5
+ <id>94</id>
6
+ <user>testuser</user>
7
+ <type>Commit</type>
8
+ <status>FIN</status>
9
+ <stoppable>no</stoppable>
10
+ <result>OK</result>
11
+ <tfin>11:14:36</tfin>
12
+ <progress>11:14:36</progress>
13
+ <details>
14
+ <line>Configuration committed successfully</line>
15
+ </details>
16
+ <warnings/>
17
+ </job>
18
+ </result>
19
+ </response>
@@ -0,0 +1,5 @@
1
+ <response status="error">
2
+ <msg>
3
+ <line>job 4 not found</line>
4
+ </msg>
5
+ </response>
@@ -0,0 +1,43 @@
1
+ require "palo_alto/v6/job_api"
2
+ require "palo_alto/helpers/rest"
3
+ require "nokogiri"
4
+
5
+ describe "PaloAlto::V6::JobApi" do
6
+ # dummy class to demonstrate functionality
7
+ class DummyClass
8
+ extend PaloAlto::V6::JobApi
9
+
10
+ def self.endpoint
11
+ "https://some.host:80/api/"
12
+ end
13
+
14
+ def self.auth_key
15
+ "OIGHOEIHT()*#Y"
16
+ end
17
+ end
18
+
19
+ describe ".job(id)" do
20
+ let(:job_id) { "4" }
21
+ let(:job_xml) { File.open(fixture_file("job.xml")).read }
22
+ let(:job_not_found_xml) { File.open(fixture_file("job_not_found.xml")).read }
23
+
24
+ describe "when the job exists" do
25
+ it "parses the XML response into the required format" do
26
+ expect(PaloAlto::Helpers::Rest).to receive(:make_request).and_return(job_xml)
27
+ job_info = DummyClass.operational_job(job_id: job_id)
28
+
29
+ expect(job_info["response"]["result"]["job"]["status"]).to eq("FIN")
30
+ end
31
+ end
32
+
33
+ describe "when the job does not exist" do
34
+ it "returns XML indicating no job exists" do
35
+ expect(PaloAlto::Helpers::Rest).to receive(:make_request).and_return(job_not_found_xml)
36
+ job_info = DummyClass.operational_job(job_id: job_id)
37
+
38
+ expect(job_info["response"]["status"]).to eq("error")
39
+ expect(job_info["response"]["msg"]["line"]).to eq("job #{job_id} not found")
40
+ end
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-paloalto-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Karimi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: crack
@@ -155,6 +155,7 @@ files:
155
155
  - lib/palo_alto/v6/api.rb
156
156
  - lib/palo_alto/v6/commit_api.rb
157
157
  - lib/palo_alto/v6/device_api.rb
158
+ - lib/palo_alto/v6/job_api.rb
158
159
  - lib/palo_alto/v6/log_api.rb
159
160
  - lib/palo_alto/v6/security_rule_api.rb
160
161
  - lib/palo_alto/v6/virtual_system_api.rb
@@ -173,6 +174,8 @@ files:
173
174
  - spec/fixtures/commit_in_progress.xml
174
175
  - spec/fixtures/devices.xml
175
176
  - spec/fixtures/failure.xml
177
+ - spec/fixtures/job.xml
178
+ - spec/fixtures/job_not_found.xml
176
179
  - spec/fixtures/log_complete.xml
177
180
  - spec/fixtures/log_in_progress.xml
178
181
  - spec/fixtures/log_job.xml
@@ -209,6 +212,7 @@ files:
209
212
  - spec/lib/palo-alto/v6/api_spec.rb
210
213
  - spec/lib/palo-alto/v6/commit_api_spec.rb
211
214
  - spec/lib/palo-alto/v6/device_api_spec.rb
215
+ - spec/lib/palo-alto/v6/job_api_spec.rb
212
216
  - spec/lib/palo-alto/v6/log_api_spec.rb
213
217
  - spec/lib/palo-alto/v6/security_rule_api_spec.rb
214
218
  - spec/lib/palo-alto/v6/virtual_system_api_spec.rb
@@ -252,6 +256,8 @@ test_files:
252
256
  - spec/fixtures/commit_in_progress.xml
253
257
  - spec/fixtures/devices.xml
254
258
  - spec/fixtures/failure.xml
259
+ - spec/fixtures/job.xml
260
+ - spec/fixtures/job_not_found.xml
255
261
  - spec/fixtures/log_complete.xml
256
262
  - spec/fixtures/log_in_progress.xml
257
263
  - spec/fixtures/log_job.xml
@@ -288,6 +294,7 @@ test_files:
288
294
  - spec/lib/palo-alto/v6/api_spec.rb
289
295
  - spec/lib/palo-alto/v6/commit_api_spec.rb
290
296
  - spec/lib/palo-alto/v6/device_api_spec.rb
297
+ - spec/lib/palo-alto/v6/job_api_spec.rb
291
298
  - spec/lib/palo-alto/v6/log_api_spec.rb
292
299
  - spec/lib/palo-alto/v6/security_rule_api_spec.rb
293
300
  - spec/lib/palo-alto/v6/virtual_system_api_spec.rb