akamai_api 0.3.0 → 0.3.1

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: cf0e390a75e4360e9ed155a456bbcb8c56d6ac20
4
- data.tar.gz: 27a3d66cb0f02ad1f709866256208f37a8ba3d51
3
+ metadata.gz: cd1e48a3fd2c4b5e7a64c03bbe1f7e65395aec0f
4
+ data.tar.gz: 212bf8e510fa426b453463094a34da2a47c91def
5
5
  SHA512:
6
- metadata.gz: 351490cd8497f8abb51379f8aaaecca6751a3abfcf50feaa8fd0978df8618f19b52b7a4021dbfab1c594fbaf692c2c56c04d6c86139f1bd5f8a0cea41befa3b8
7
- data.tar.gz: bac0791728d4d40d7b511b66bafa2bb218281c426e0542ddd940e0374cd46d02696a021cadfda9d83b9c5d9d519b8e683acaec45a0038ad794b0856f6f4380ef
6
+ metadata.gz: 35ab110e7a21a81af43e66ca521af50388b784f774fd150a3249ef74d6fbadc7227771c0301efe316fdd2a1955f58500ba1c560b48ea455db4b2925a0191d6c0
7
+ data.tar.gz: 2d06963b02cfc69145d3c57a32b7d152f8ed99fed1728f4ce7615b3774f72f6d3e386606e01a9d29e558e60aab8cad38599a0c3522d932f3ad18bc7eb06e4332
@@ -22,6 +22,11 @@ module AkamaiApi::CLI::CCU
22
22
  :desc => 'Optional argument used to specify the environment. Usually you will not need this option'
23
23
  method_option :banner => "foo@foo.com bar@bar.com",
24
24
  :desc => 'Email(s) used to send notification when the purge has been completed'
25
+ method_option :poll,
26
+ :desc => 'whether or not to poll for status',
27
+ :type => :boolean,
28
+ :default => false
29
+
25
30
  def invalidate(*arls)
26
31
  purge_action :invalidate, arls
27
32
  end
@@ -32,11 +37,29 @@ module AkamaiApi::CLI::CCU
32
37
  load_config
33
38
  res = AkamaiApi::CCU.purge type, :arl, arls, :domain => options[:domain]
34
39
  puts PurgeRenderer.new(res).render
40
+
41
+ if options[:poll] == true && res.code == 201
42
+ poll_status res
43
+ end
35
44
  rescue AkamaiApi::CCU::Error
36
45
  puts StatusRenderer.new($!).render_error
37
46
  rescue AkamaiApi::Unauthorized
38
47
  puts 'Your login credentials are invalid.'
39
48
  end
40
49
  end
50
+
51
+ no_commands do
52
+ def poll_status purge_response
53
+ if purge_response.time_to_wait
54
+ status = AkamaiApi::CCU.status purge_response.uri
55
+ while status.completed_at.nil?
56
+ puts StatusRenderer.new(status).render
57
+ sleep 60
58
+ status = AkamaiApi::CCU.status purge_response.uri
59
+ end
60
+ end
61
+ puts StatusRenderer.new(status).render
62
+ end
63
+ end
41
64
  end
42
65
  end
@@ -1,3 +1,3 @@
1
1
  module AkamaiApi
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ module AkamaiApi
4
+ describe CLI::CCU::Arl do
5
+ describe 'invalidate' do
6
+ it 'polls for status' do
7
+ arl = CLI::CCU::Arl.new
8
+
9
+ allow(arl).to receive(:load_config)
10
+ allow(arl).to receive(:options).and_return({:poll => true})
11
+
12
+ res = double()
13
+ expect(CCU).to receive(:purge).and_return(res)
14
+
15
+ expect(res).to receive(:code).and_return(201)
16
+ expect(res).to receive(:time_to_wait).and_return(true)
17
+
18
+ renderer = double()
19
+ allow(renderer).to receive(:render)
20
+ allow(CLI::CCU::PurgeRenderer).to receive(:new).and_return(renderer)
21
+
22
+ status_res1 = double()
23
+ allow(status_res1).to receive(:code).and_return(201)
24
+
25
+ status_res2 = double()
26
+ allow(status_res2).to receive(:completed_at).and_return(nil, nil, true)
27
+
28
+ allow(CLI::CCU::StatusRenderer).to receive(:new).and_return(renderer)
29
+
30
+ allow(res).to receive(:uri).and_return("status_uri")
31
+
32
+ expect(CCU).to receive(:status).exactly(3).times.with("status_uri").and_return(status_res2)
33
+
34
+ expect(arl).to receive(:sleep).exactly(2).times.with(60)
35
+
36
+ arl.invalidate("test_uri")
37
+ end
38
+ end
39
+ end
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akamai_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicola Racco
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-03 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -238,6 +238,7 @@ files:
238
238
  - spec/lib/akamai_api/ccu/status/request_spec.rb
239
239
  - spec/lib/akamai_api/ccu/status/response_spec.rb
240
240
  - spec/lib/akamai_api/ccu_spec.rb
241
+ - spec/lib/akamai_api/cli/ccu/arl_spec.rb
241
242
  - spec/lib/akamai_api/cli/ccu/status_renderer_spec.rb
242
243
  - spec/lib/akamai_api/eccu/destroy_request_spec.rb
243
244
  - spec/lib/akamai_api/eccu/find_request_spec.rb
@@ -269,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
270
  version: '0'
270
271
  requirements: []
271
272
  rubyforge_project:
272
- rubygems_version: 2.2.2
273
+ rubygems_version: 2.4.6
273
274
  signing_key:
274
275
  specification_version: 4
275
276
  summary: Ruby toolkit to work with Akamai Content Control Utility API
@@ -314,6 +315,7 @@ test_files:
314
315
  - spec/lib/akamai_api/ccu/status/request_spec.rb
315
316
  - spec/lib/akamai_api/ccu/status/response_spec.rb
316
317
  - spec/lib/akamai_api/ccu_spec.rb
318
+ - spec/lib/akamai_api/cli/ccu/arl_spec.rb
317
319
  - spec/lib/akamai_api/cli/ccu/status_renderer_spec.rb
318
320
  - spec/lib/akamai_api/eccu/destroy_request_spec.rb
319
321
  - spec/lib/akamai_api/eccu/find_request_spec.rb