akamai_api 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/Guardfile +5 -15
  3. data/README.md +106 -36
  4. data/Thorfile +5 -0
  5. data/akamai_api.gemspec +6 -3
  6. data/bin/akamai_api +1 -2
  7. data/cassettes/akamai_api_ccu_arl_invalidate/invalid_credentials.yml +37 -0
  8. data/cassettes/akamai_api_ccu_arl_invalidate/invalid_item.yml +36 -0
  9. data/cassettes/akamai_api_ccu_arl_invalidate/multiple_items.yml +38 -0
  10. data/cassettes/akamai_api_ccu_arl_invalidate/single_item.yml +38 -0
  11. data/cassettes/akamai_api_ccu_arl_remove/invalid_credentials.yml +37 -0
  12. data/cassettes/akamai_api_ccu_arl_remove/invalid_item.yml +36 -0
  13. data/cassettes/akamai_api_ccu_arl_remove/multiple_items.yml +38 -0
  14. data/cassettes/akamai_api_ccu_arl_remove/single_item.yml +38 -0
  15. data/cassettes/akamai_api_ccu_cpcode_invalidate/invalid_credentials.yml +37 -0
  16. data/cassettes/akamai_api_ccu_cpcode_invalidate/invalid_item.yml +36 -0
  17. data/cassettes/akamai_api_ccu_cpcode_invalidate/multiple_items.yml +38 -0
  18. data/cassettes/akamai_api_ccu_cpcode_invalidate/single_item.yml +38 -0
  19. data/cassettes/akamai_api_ccu_cpcode_remove/invalid_credentials.yml +37 -0
  20. data/cassettes/akamai_api_ccu_cpcode_remove/invalid_item.yml +36 -0
  21. data/cassettes/akamai_api_ccu_cpcode_remove/multiple_items.yml +38 -0
  22. data/cassettes/akamai_api_ccu_cpcode_remove/single_item.yml +38 -0
  23. data/cassettes/akamai_api_ccu_purge_status/completed_request.yml +35 -0
  24. data/cassettes/akamai_api_ccu_purge_status/enqueued_request.yml +35 -0
  25. data/cassettes/akamai_api_ccu_purge_status/invalid_credentials.yml +35 -0
  26. data/cassettes/akamai_api_ccu_purge_status/not_found_request.yml +37 -0
  27. data/cassettes/akamai_api_ccu_status/invalid_credentials.yml +35 -0
  28. data/cassettes/akamai_api_ccu_status/valid_credentials.yml +34 -0
  29. data/cassettes/akamai_api_eccu_last_request/invalid_credentials.yml +68 -0
  30. data/cassettes/akamai_api_eccu_last_request/valid_credentials.yml +140 -0
  31. data/cassettes/akamai_api_eccu_publish/invalid_credentials.yml +73 -0
  32. data/cassettes/akamai_api_eccu_publish/invalid_domain.yml +60 -0
  33. data/cassettes/akamai_api_eccu_publish/successful.yml +126 -0
  34. data/cassettes/akamai_api_eccu_requests/invalid_credentials.yml +68 -0
  35. data/cassettes/akamai_api_eccu_requests/valid_credentials.yml +325 -0
  36. data/features/ccu_arl_invalidate.feature +83 -0
  37. data/features/ccu_arl_remove.feature +83 -0
  38. data/features/ccu_cpcode_invalidate.feature +83 -0
  39. data/features/ccu_cpcode_remove.feature +83 -0
  40. data/features/ccu_purge_status.feature +83 -0
  41. data/features/ccu_status.feature +31 -0
  42. data/features/eccu_last_request.feature +47 -0
  43. data/features/eccu_publish.feature +98 -0
  44. data/features/eccu_requests.feature +43 -0
  45. data/features/step_definitions/contain_multiple_times_steps.rb +3 -0
  46. data/features/support/env.rb +58 -0
  47. data/lib/akamai_api/ccu/purge/request.rb +76 -0
  48. data/lib/akamai_api/ccu/purge/response.rb +31 -0
  49. data/lib/akamai_api/ccu/purge.rb +5 -0
  50. data/lib/akamai_api/ccu/purge_status/not_found_response.rb +9 -0
  51. data/lib/akamai_api/ccu/purge_status/request.rb +32 -0
  52. data/lib/akamai_api/ccu/purge_status/response.rb +19 -0
  53. data/lib/akamai_api/ccu/purge_status/successful_response.rb +25 -0
  54. data/lib/akamai_api/ccu/purge_status.rb +10 -0
  55. data/lib/akamai_api/ccu/response.rb +18 -0
  56. data/lib/akamai_api/ccu/status/request.rb +23 -0
  57. data/lib/akamai_api/ccu/status/response.rb +11 -0
  58. data/lib/akamai_api/ccu/status.rb +2 -0
  59. data/lib/akamai_api/ccu.rb +14 -50
  60. data/lib/akamai_api/cli/app.rb +2 -2
  61. data/lib/akamai_api/cli/ccu/arl.rb +36 -0
  62. data/lib/akamai_api/cli/ccu/base.rb +18 -0
  63. data/lib/akamai_api/cli/ccu/cp_code.rb +39 -0
  64. data/lib/akamai_api/cli/ccu/purge_renderer.rb +49 -0
  65. data/lib/akamai_api/cli/ccu/status_renderer.rb +69 -0
  66. data/lib/akamai_api/cli/ccu.rb +5 -10
  67. data/lib/akamai_api/cli/eccu/entry_renderer.rb +63 -0
  68. data/lib/akamai_api/cli/eccu.rb +16 -14
  69. data/lib/akamai_api/cli.rb +7 -2
  70. data/lib/akamai_api/eccu_request.rb +19 -1
  71. data/lib/akamai_api/version.rb +1 -1
  72. data/lib/akamai_api.rb +3 -1
  73. data/spec/features/ccu/purge_request_spec.rb +94 -0
  74. data/spec/features/ccu/purge_status_request_spec.rb +31 -0
  75. data/spec/features/ccu/status_request_spec.rb +17 -0
  76. data/spec/fixtures/ccu/successful_purge.json +1 -0
  77. data/spec/lib/akamai_api/ccu/purge/request_spec.rb +124 -0
  78. data/spec/lib/akamai_api/ccu/purge/response_spec.rb +54 -0
  79. data/spec/lib/akamai_api/ccu/purge_status/not_found_response_spec.rb +41 -0
  80. data/spec/lib/akamai_api/ccu/purge_status/request_spec.rb +64 -0
  81. data/spec/lib/akamai_api/ccu/purge_status/successful_response_spec.rb +86 -0
  82. data/spec/lib/akamai_api/ccu/response_spec.rb +15 -0
  83. data/spec/lib/akamai_api/ccu/status/request_spec.rb +22 -0
  84. data/spec/lib/akamai_api/ccu/status/response_spec.rb +29 -0
  85. data/spec/lib/akamai_api/ccu_spec.rb +49 -61
  86. data/spec/lib/akamai_api/cli/ccu/status_renderer_spec.rb +36 -0
  87. data/spec/lib/akamai_api/eccu_request_spec.rb +5 -5
  88. data/spec/spec_helper.rb +21 -1
  89. metadata +163 -26
  90. data/lib/akamai_api/ccu_response.rb +0 -51
  91. data/lib/akamai_api/cli/ccu_arl.rb +0 -40
  92. data/lib/akamai_api/cli/ccu_cp_code.rb +0 -48
  93. data/lib/akamai_api/cli/template.rb +0 -36
  94. data/lib/akamai_api/cp_code.rb +0 -33
  95. data/spec/fixtures/ccu/successful_purge.xml +0 -15
  96. data/spec/fixtures/cp_code/collection.xml +0 -21
  97. data/spec/fixtures/cp_code/single.xml +0 -16
  98. data/spec/lib/akamai_api/cp_code_spec.rb +0 -47
  99. data/wsdls/cpcode.wsdl +0 -2765
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,27 @@
1
1
  require File.expand_path '../../lib/akamai_api', __FILE__
2
+ require File.expand_path '../../lib/akamai_api/cli', __FILE__
2
3
  require File.expand_path '../auth.rb', __FILE__
3
4
 
4
5
  require 'savon/mock/spec_helper'
6
+ require 'webmock/rspec'
7
+ require 'vcr'
8
+
9
+ VCR.configure do |c|
10
+ c.cassette_library_dir = 'cassettes'
11
+ c.hook_into :webmock
12
+ c.default_cassette_options = {
13
+ record: :once
14
+ }
15
+ c.configure_rspec_metadata!
16
+ c.after_http_request do |request|
17
+ request.uri.gsub! AkamaiApi.config[:auth].first, 'USERNAME'
18
+ request.uri.gsub! AkamaiApi.config[:auth].last, 'PASSWORD'
19
+ end
20
+ c.before_playback do |i|
21
+ i.request.uri.gsub! 'USERNAME', AkamaiApi.config[:auth].first
22
+ i.request.uri.gsub! 'PASSWORD', AkamaiApi.config[:auth].last
23
+ end
24
+ end
5
25
 
6
26
  # Savon::Spec::Fixture.path = File.expand_path '../fixtures', __FILE__
7
27
  Dir[File.expand_path '../support/**/*.rb', __FILE__].each do |f|
@@ -14,4 +34,4 @@ RSpec.configure do |config|
14
34
  config.filter_run :focus
15
35
 
16
36
  config.order = 'random'
17
- end
37
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akamai_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
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-05-14 00:00:00.000000000 Z
11
+ date: 2014-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.13.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.13.1
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: activesupport
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -79,33 +93,75 @@ dependencies:
79
93
  - !ruby/object:Gem::Version
80
94
  version: '3.0'
81
95
  - !ruby/object:Gem::Dependency
82
- name: rspec
96
+ name: guard-rspec
83
97
  requirement: !ruby/object:Gem::Requirement
84
98
  requirements:
85
- - - ~>
99
+ - - '>='
86
100
  - !ruby/object:Gem::Version
87
- version: '2.11'
101
+ version: '0'
88
102
  type: :development
89
103
  prerelease: false
90
104
  version_requirements: !ruby/object:Gem::Requirement
91
105
  requirements:
92
- - - ~>
106
+ - - '>='
93
107
  - !ruby/object:Gem::Version
94
- version: '2.11'
108
+ version: '0'
95
109
  - !ruby/object:Gem::Dependency
96
- name: guard-rspec
110
+ name: guard-cucumber
97
111
  requirement: !ruby/object:Gem::Requirement
98
112
  requirements:
99
- - - ~>
113
+ - - '>='
100
114
  - !ruby/object:Gem::Version
101
- version: 3.0.2
115
+ version: '0'
102
116
  type: :development
103
117
  prerelease: false
104
118
  version_requirements: !ruby/object:Gem::Requirement
105
119
  requirements:
106
- - - ~>
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ - !ruby/object:Gem::Dependency
124
+ name: aruba
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ type: :development
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ - !ruby/object:Gem::Dependency
138
+ name: webmock
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ type: :development
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ - !ruby/object:Gem::Dependency
152
+ name: vcr
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ type: :development
159
+ prerelease: false
160
+ version_requirements: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - '>='
107
163
  - !ruby/object:Gem::Version
108
- version: 3.0.2
164
+ version: '0'
109
165
  description: Ruby toolkit to work with Akamai Content Control Utility API
110
166
  email:
111
167
  - nicola@nicolaracco.com
@@ -123,24 +179,78 @@ files:
123
179
  - Thorfile
124
180
  - akamai_api.gemspec
125
181
  - bin/akamai_api
182
+ - cassettes/akamai_api_ccu_arl_invalidate/invalid_credentials.yml
183
+ - cassettes/akamai_api_ccu_arl_invalidate/invalid_item.yml
184
+ - cassettes/akamai_api_ccu_arl_invalidate/multiple_items.yml
185
+ - cassettes/akamai_api_ccu_arl_invalidate/single_item.yml
186
+ - cassettes/akamai_api_ccu_arl_remove/invalid_credentials.yml
187
+ - cassettes/akamai_api_ccu_arl_remove/invalid_item.yml
188
+ - cassettes/akamai_api_ccu_arl_remove/multiple_items.yml
189
+ - cassettes/akamai_api_ccu_arl_remove/single_item.yml
190
+ - cassettes/akamai_api_ccu_cpcode_invalidate/invalid_credentials.yml
191
+ - cassettes/akamai_api_ccu_cpcode_invalidate/invalid_item.yml
192
+ - cassettes/akamai_api_ccu_cpcode_invalidate/multiple_items.yml
193
+ - cassettes/akamai_api_ccu_cpcode_invalidate/single_item.yml
194
+ - cassettes/akamai_api_ccu_cpcode_remove/invalid_credentials.yml
195
+ - cassettes/akamai_api_ccu_cpcode_remove/invalid_item.yml
196
+ - cassettes/akamai_api_ccu_cpcode_remove/multiple_items.yml
197
+ - cassettes/akamai_api_ccu_cpcode_remove/single_item.yml
198
+ - cassettes/akamai_api_ccu_purge_status/completed_request.yml
199
+ - cassettes/akamai_api_ccu_purge_status/enqueued_request.yml
200
+ - cassettes/akamai_api_ccu_purge_status/invalid_credentials.yml
201
+ - cassettes/akamai_api_ccu_purge_status/not_found_request.yml
202
+ - cassettes/akamai_api_ccu_status/invalid_credentials.yml
203
+ - cassettes/akamai_api_ccu_status/valid_credentials.yml
204
+ - cassettes/akamai_api_eccu_last_request/invalid_credentials.yml
205
+ - cassettes/akamai_api_eccu_last_request/valid_credentials.yml
206
+ - cassettes/akamai_api_eccu_publish/invalid_credentials.yml
207
+ - cassettes/akamai_api_eccu_publish/invalid_domain.yml
208
+ - cassettes/akamai_api_eccu_publish/successful.yml
209
+ - cassettes/akamai_api_eccu_requests/invalid_credentials.yml
210
+ - cassettes/akamai_api_eccu_requests/valid_credentials.yml
211
+ - features/ccu_arl_invalidate.feature
212
+ - features/ccu_arl_remove.feature
213
+ - features/ccu_cpcode_invalidate.feature
214
+ - features/ccu_cpcode_remove.feature
215
+ - features/ccu_purge_status.feature
216
+ - features/ccu_status.feature
217
+ - features/eccu_last_request.feature
218
+ - features/eccu_publish.feature
219
+ - features/eccu_requests.feature
220
+ - features/step_definitions/contain_multiple_times_steps.rb
221
+ - features/support/env.rb
126
222
  - lib/akamai_api.rb
127
223
  - lib/akamai_api/ccu.rb
128
- - lib/akamai_api/ccu_response.rb
224
+ - lib/akamai_api/ccu/purge.rb
225
+ - lib/akamai_api/ccu/purge/request.rb
226
+ - lib/akamai_api/ccu/purge/response.rb
227
+ - lib/akamai_api/ccu/purge_status.rb
228
+ - lib/akamai_api/ccu/purge_status/not_found_response.rb
229
+ - lib/akamai_api/ccu/purge_status/request.rb
230
+ - lib/akamai_api/ccu/purge_status/response.rb
231
+ - lib/akamai_api/ccu/purge_status/successful_response.rb
232
+ - lib/akamai_api/ccu/response.rb
233
+ - lib/akamai_api/ccu/status.rb
234
+ - lib/akamai_api/ccu/status/request.rb
235
+ - lib/akamai_api/ccu/status/response.rb
129
236
  - lib/akamai_api/cli.rb
130
237
  - lib/akamai_api/cli/app.rb
131
238
  - lib/akamai_api/cli/ccu.rb
132
- - lib/akamai_api/cli/ccu_arl.rb
133
- - lib/akamai_api/cli/ccu_cp_code.rb
239
+ - lib/akamai_api/cli/ccu/arl.rb
240
+ - lib/akamai_api/cli/ccu/base.rb
241
+ - lib/akamai_api/cli/ccu/cp_code.rb
242
+ - lib/akamai_api/cli/ccu/purge_renderer.rb
243
+ - lib/akamai_api/cli/ccu/status_renderer.rb
134
244
  - lib/akamai_api/cli/command.rb
135
245
  - lib/akamai_api/cli/eccu.rb
136
- - lib/akamai_api/cli/template.rb
137
- - lib/akamai_api/cp_code.rb
246
+ - lib/akamai_api/cli/eccu/entry_renderer.rb
138
247
  - lib/akamai_api/eccu_request.rb
139
248
  - lib/akamai_api/soap_body.rb
140
249
  - lib/akamai_api/version.rb
141
- - spec/fixtures/ccu/successful_purge.xml
142
- - spec/fixtures/cp_code/collection.xml
143
- - spec/fixtures/cp_code/single.xml
250
+ - spec/features/ccu/purge_request_spec.rb
251
+ - spec/features/ccu/purge_status_request_spec.rb
252
+ - spec/features/ccu/status_request_spec.rb
253
+ - spec/fixtures/ccu/successful_purge.json
144
254
  - spec/fixtures/eccu/delete/successful.xml
145
255
  - spec/fixtures/eccu/get_ids/successful.xml
146
256
  - spec/fixtures/eccu/get_info/successful.xml
@@ -150,14 +260,21 @@ files:
150
260
  - spec/fixtures/eccu/upload/fault.xml
151
261
  - spec/fixtures/eccu/upload/successful.xml
152
262
  - spec/fixtures/eccu_request.xml
263
+ - spec/lib/akamai_api/ccu/purge/request_spec.rb
264
+ - spec/lib/akamai_api/ccu/purge/response_spec.rb
265
+ - spec/lib/akamai_api/ccu/purge_status/not_found_response_spec.rb
266
+ - spec/lib/akamai_api/ccu/purge_status/request_spec.rb
267
+ - spec/lib/akamai_api/ccu/purge_status/successful_response_spec.rb
268
+ - spec/lib/akamai_api/ccu/response_spec.rb
269
+ - spec/lib/akamai_api/ccu/status/request_spec.rb
270
+ - spec/lib/akamai_api/ccu/status/response_spec.rb
153
271
  - spec/lib/akamai_api/ccu_spec.rb
154
- - spec/lib/akamai_api/cp_code_spec.rb
272
+ - spec/lib/akamai_api/cli/ccu/status_renderer_spec.rb
155
273
  - spec/lib/akamai_api/eccu_request_spec.rb
156
274
  - spec/lib/akamai_api/soap_body_spec.rb
157
275
  - spec/spec_helper.rb
158
276
  - spec/support/savon_backports.rb
159
277
  - wsdls/ccuapi.wsdl
160
- - wsdls/cpcode.wsdl
161
278
  - wsdls/eccu.wsdl
162
279
  homepage: https://github.com/nicolaracco/akamai_api
163
280
  licenses: []
@@ -183,9 +300,21 @@ signing_key:
183
300
  specification_version: 4
184
301
  summary: Ruby toolkit to work with Akamai Content Control Utility API
185
302
  test_files:
186
- - spec/fixtures/ccu/successful_purge.xml
187
- - spec/fixtures/cp_code/collection.xml
188
- - spec/fixtures/cp_code/single.xml
303
+ - features/ccu_arl_invalidate.feature
304
+ - features/ccu_arl_remove.feature
305
+ - features/ccu_cpcode_invalidate.feature
306
+ - features/ccu_cpcode_remove.feature
307
+ - features/ccu_purge_status.feature
308
+ - features/ccu_status.feature
309
+ - features/eccu_last_request.feature
310
+ - features/eccu_publish.feature
311
+ - features/eccu_requests.feature
312
+ - features/step_definitions/contain_multiple_times_steps.rb
313
+ - features/support/env.rb
314
+ - spec/features/ccu/purge_request_spec.rb
315
+ - spec/features/ccu/purge_status_request_spec.rb
316
+ - spec/features/ccu/status_request_spec.rb
317
+ - spec/fixtures/ccu/successful_purge.json
189
318
  - spec/fixtures/eccu/delete/successful.xml
190
319
  - spec/fixtures/eccu/get_ids/successful.xml
191
320
  - spec/fixtures/eccu/get_info/successful.xml
@@ -195,8 +324,16 @@ test_files:
195
324
  - spec/fixtures/eccu/upload/fault.xml
196
325
  - spec/fixtures/eccu/upload/successful.xml
197
326
  - spec/fixtures/eccu_request.xml
327
+ - spec/lib/akamai_api/ccu/purge/request_spec.rb
328
+ - spec/lib/akamai_api/ccu/purge/response_spec.rb
329
+ - spec/lib/akamai_api/ccu/purge_status/not_found_response_spec.rb
330
+ - spec/lib/akamai_api/ccu/purge_status/request_spec.rb
331
+ - spec/lib/akamai_api/ccu/purge_status/successful_response_spec.rb
332
+ - spec/lib/akamai_api/ccu/response_spec.rb
333
+ - spec/lib/akamai_api/ccu/status/request_spec.rb
334
+ - spec/lib/akamai_api/ccu/status/response_spec.rb
198
335
  - spec/lib/akamai_api/ccu_spec.rb
199
- - spec/lib/akamai_api/cp_code_spec.rb
336
+ - spec/lib/akamai_api/cli/ccu/status_renderer_spec.rb
200
337
  - spec/lib/akamai_api/eccu_request_spec.rb
201
338
  - spec/lib/akamai_api/soap_body_spec.rb
202
339
  - spec/spec_helper.rb
@@ -1,51 +0,0 @@
1
- require 'ostruct'
2
- require 'active_support/core_ext/module/delegation'
3
-
4
- module AkamaiApi
5
- class CcuResponse
6
- attr_reader :raw_body, :requested_items
7
-
8
- def initialize(response, requested_items)
9
- @raw_body = response.body
10
- @requested_items = requested_items
11
- end
12
-
13
- delegate :result_code, :result_msg, :session_id, :est_time, :uri_index, :to => :body
14
- alias message result_msg
15
-
16
- def body
17
- @body ||= OpenStruct.new(raw_body[:purge_request_response][:return])
18
- end
19
-
20
- def code
21
- result_code.to_i
22
- end
23
-
24
- def estimated_time
25
- est_time.to_i
26
- end
27
-
28
- def uri
29
- int_index = uri_index.to_i
30
- int_index >= 0 && requested_items[int_index] || nil
31
- end
32
-
33
- def status
34
- case code
35
- when (100..199) then 'Successful Request'
36
- when (200..299) then 'Warning. The removal request has been accepted'
37
- when 301 then 'Invalid username or password'
38
- when 302 then 'Bad syntax for an option'
39
- when 303 then 'Invalid value for an option'
40
- when 304 then 'Option already provided'
41
- when 320 then 'URI provided'
42
- when 321 then 'Format of ARL/URL is invalid'
43
- when 322 then 'You are not authorized to purge this ARL/URL'
44
- when 323 then 'ARL/URL illegal'
45
- when 332 then 'Maximum number of ARL/URLs in outstanding purge requests exceeded'
46
- when (300..399) then 'Bad or invalid request'
47
- when (400..499) then 'Contact Akamai Customer Care'
48
- end
49
- end
50
- end
51
- end
@@ -1,40 +0,0 @@
1
- module AkamaiApi
2
- module Cli
3
- class CcuArl < Command
4
- namespace 'ccu arl'
5
-
6
- desc 'remove http://john.com/a.txt http://www.smith.com/b.txt ...', 'Purge ARL(s) removing them from the cache'
7
- method_option :domain, :type => :string, :aliases => '-d',
8
- :banner => 'production|staging',
9
- :desc => 'Optional argument used to specify the environment. Usually you will not need this option'
10
- method_option :emails, :type => :array, :aliases => '-e',
11
- :banner => "foo@foo.com bar@bar.com",
12
- :desc => 'Email(s) used to send notification when the purge has been completed'
13
- def remove(*arls)
14
- purge_action :remove, arls
15
- end
16
-
17
- desc 'invalidate http://john.com/a.txt http://www.smith.com/b.txt ...', 'Purge ARL(s) marking their cache as expired'
18
- method_option :domain, :type => :string, :aliases => '-d',
19
- :banner => 'production|staging',
20
- :desc => 'Optional argument used to specify the environment. Usually you will not need this option'
21
- method_option :emails, :type => :array, :aliases => '-e',
22
- :banner => "foo@foo.com bar@bar.com",
23
- :desc => 'Email(s) used to send notification when the purge has been completed'
24
- def invalidate(*arls)
25
- purge_action :invalidate, arls
26
- end
27
-
28
- no_tasks do
29
- def purge_action type, arls
30
- raise 'You should provide at least one valid URL' if arls.blank?
31
- load_config
32
- res = AkamaiApi::Ccu.purge type, :arl, arls, :domain => options[:domain], :email => options[:emails]
33
- puts '------------'
34
- puts AkamaiApi::Cli::Template.ccu_response res
35
- puts '------------'
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,48 +0,0 @@
1
- module AkamaiApi
2
- module Cli
3
- class CcuCpCode < Command
4
- namespace 'ccu cpcode'
5
-
6
- desc 'list', 'Print the list of CP Codes'
7
- def list
8
- load_config
9
- AkamaiApi::CpCode.all.each do |cp_code|
10
- puts AkamaiApi::Cli::Template.cp_code(cp_code)
11
- end
12
- end
13
-
14
- desc 'remove CPCODE1 CPCODE2 ...', 'Purge CP Code(s) removing them from the cache'
15
- method_option :domain, :type => :string, :aliases => '-d',
16
- :banner => 'production|staging',
17
- :desc => 'Optional argument used to specify the environment. Usually you will not need this option'
18
- method_option :emails, :type => :array, :aliases => '-e',
19
- :banner => "foo@foo.com bar@bar.com",
20
- :desc => 'Email(s) used to send notification when the purge has been completed'
21
- def remove(*cpcodes)
22
- purge_action :remove, cpcodes
23
- end
24
-
25
- desc 'invalidate CPCODE1 CPCODE2 ...', 'Purge CP Code(s) marking their cache as expired'
26
- method_option :domain, :type => :string, :aliases => '-d',
27
- :banner => 'production|staging',
28
- :desc => 'Optional argument used to specify the environment. Usually you will not need this option'
29
- method_option :emails, :type => :array, :aliases => '-e',
30
- :banner => "foo@foo.com bar@bar.com",
31
- :desc => 'Email(s) used to send notification when the purge has been completed'
32
- def invalidate(*cpcodes)
33
- purge_action :invalidate, cpcodes
34
- end
35
-
36
- no_tasks do
37
- def purge_action type, cpcodes
38
- raise 'You should provide at least one valid CP Code' if cpcodes.blank?
39
- load_config
40
- res = AkamaiApi::Ccu.purge type, :cpcode, cpcodes, :domain => options[:domain], :email => options[:emails]
41
- puts '------------'
42
- puts AkamaiApi::Cli::Template.ccu_response res
43
- puts '------------'
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,36 +0,0 @@
1
- module AkamaiApi
2
- module Cli
3
- module Template
4
- def self.eccu_request request
5
- res = ["* Code : #{request.code}",
6
- "* Status : #{request.status[:code]}"]
7
- res.last << " - #{request.status[:extended]}" if request.status[:extended].present?
8
- res << " #{request.status[:update_date]}"
9
- res << "* Property: #{request.property[:name]} (#{request.property[:type]})"
10
- res << " with exact match" if request.property[:exact_match]
11
- res << "* Notes : #{request.notes}" if request.notes.present?
12
- res << "* Email : #{request.email}" if request.email
13
- res << "* Uploaded by #{request.uploaded_by} on #{request.upload_date}"
14
- if request.file[:content].present?
15
- res << "* Content:"
16
- res << request.file[:content]
17
- end
18
- res.join "\n"
19
- end
20
-
21
- def self.cp_code cpcode
22
- "#{cpcode.code}\t#{cpcode.description}"
23
- end
24
-
25
- def self.ccu_response response
26
- res = ['#### Response Details ####',
27
- "* Request ID: #{response.session_id}",
28
- "* Code: #{response.code} (#{response.status})",
29
- "* Message: #{response.message}"]
30
- res << "* Estimate Time: #{response.estimated_time} secs.;" if response.estimated_time > 0
31
- res << "* Error caused by: #{response.uri};" if response.uri
32
- res.join "\n"
33
- end
34
- end
35
- end
36
- end
@@ -1,33 +0,0 @@
1
- module AkamaiApi
2
- class CpCode
3
- attr_accessor :code, :description, :service
4
-
5
- def initialize attributes
6
- attributes.each do |key, value|
7
- send "#{key}=", value
8
- end
9
- end
10
-
11
- def self.all
12
- response = client.call(:get_cp_codes).body[:multi_ref]
13
- Array.wrap(response).map do |hash|
14
- new({
15
- :code => hash[:cpcode],
16
- :description => hash[:description],
17
- :service => hash[:service],
18
- })
19
- end
20
- end
21
-
22
- private
23
-
24
- def self.client
25
- savon_args = {
26
- :wsdl => File.expand_path('../../../wsdls/cpcode.wsdl', __FILE__),
27
- :basic_auth => AkamaiApi.config[:auth],
28
- :log => AkamaiApi.config[:log]
29
- }
30
- Savon.client savon_args
31
- end
32
- end
33
- end
@@ -1,15 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
3
- <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsd1="http://www.w3.org/1999/XMLSchema" xmlns:xsd2="http://www.w3.org/2000/10/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi1="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsi2="http://www.w3.org/2000/10/XMLSchema-instance">
4
- <ns0:purgeRequestResponse xmlns:ns0="http://www.akamai.com/purge">
5
- <return xsi1:type="ns0:PurgeResult" xsi2:type="ns0:PurgeResult" xsi:type="ns0:PurgeResult">
6
- <resultCode xsi1:type="xsd1:int" xsi2:type="xsd1:int" xsi:type="xsd1:int">100</resultCode>
7
- <resultMsg xsi1:type="xsd1:string" xsi2:type="xsd1:string" xsi:type="xsd1:string">Success.</resultMsg>
8
- <sessionID xsi1:type="xsd1:string" xsi2:type="xsd1:string" xsi:type="xsd1:string">97870328-018c-11e2-aabc-489beabc489b</sessionID>
9
- <estTime xsi1:type="xsd1:int" xsi2:type="xsd1:int" xsi:type="xsd1:int">420</estTime>
10
- <uriIndex xsi1:type="xsd1:int" xsi2:type="xsd1:int" xsi:type="xsd1:int">-1</uriIndex>
11
- <modifiers SOAP-ENC:arrayType="xsd1:string[0]" xsi1:null="true" xsi2:null="true" xsi:nil="true"/>
12
- </return>
13
- </ns0:purgeRequestResponse>
14
- </SOAP-ENV:Body>
15
- </SOAP-ENV:Envelope>
@@ -1,21 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
- <soapenv:Body>
4
- <getCPCodesResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
5
- <getCPCodesReturn soapenc:arrayType="ns1:CPCodeInfo[34]" xsi:type="soapenc:Array" xmlns:ns1="https://control.akamai.com/Data.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
6
- <getCPCodesReturn href="#id0"/>
7
- <getCPCodesReturn href="#id1"/>
8
- </getCPCodesReturn>
9
- </getCPCodesResponse>
10
- <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:CPCodeInfo" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="https://control.akamai.com/Data.xsd">
11
- <cpcode xsi:type="xsd:int">12345</cpcode>
12
- <description xsi:type="xsd:string">Foo Site</description>
13
- <service xsi:type="xsd:string">Site_Accel::Site_Accel</service>
14
- </multiRef>
15
- <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:CPCodeInfo" xmlns:ns3="https://control.akamai.com/Data.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
16
- <cpcode xsi:type="xsd:int">23456</cpcode>
17
- <description xsi:type="xsd:string">Sample Site</description>
18
- <service xsi:type="xsd:string">Site_Accel::Site_Accel</service>
19
- </multiRef>
20
- </soapenv:Body>
21
- </soapenv:Envelope>
@@ -1,16 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
- <soapenv:Body>
4
- <getCPCodesResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
5
- <getCPCodesReturn soapenc:arrayType="ns1:CPCodeInfo[34]" xsi:type="soapenc:Array" xmlns:ns1="https://control.akamai.com/Data.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
6
- <getCPCodesReturn href="#id0"/>
7
- <getCPCodesReturn href="#id1"/>
8
- </getCPCodesReturn>
9
- </getCPCodesResponse>
10
- <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:CPCodeInfo" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="https://control.akamai.com/Data.xsd">
11
- <cpcode xsi:type="xsd:int">12345</cpcode>
12
- <description xsi:type="xsd:string">Foo Site</description>
13
- <service xsi:type="xsd:string">Site_Accel::Site_Accel</service>
14
- </multiRef>
15
- </soapenv:Body>
16
- </soapenv:Envelope>
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe AkamaiApi::CpCode do
4
- include Savon::SpecHelper
5
-
6
- before(:all) { savon.mock! }
7
- after(:all) { savon.unmock! }
8
-
9
- describe '::all' do
10
- context 'when there are multiple cp codes' do
11
- before do
12
- fixture = File.read 'spec/fixtures/cp_code/collection.xml'
13
- savon.expects(:get_cp_codes).returns(fixture)
14
- end
15
-
16
- it 'returns a collection of cp codes' do
17
- AkamaiApi::CpCode.all.each { |o| o.should be_a AkamaiApi::CpCode }
18
- end
19
-
20
- it 'returns a collection with the correct size' do
21
- AkamaiApi::CpCode.all.count.should == 2
22
- end
23
-
24
- it 'correctly fills each cp code object' do
25
- first = AkamaiApi::CpCode.all.first
26
- first.code.should == '12345'
27
- first.description.should == 'Foo Site'
28
- first.service.should == 'Site_Accel::Site_Accel'
29
- end
30
- end
31
-
32
- context 'when there is only one cp code' do
33
- before do
34
- fixture = File.read 'spec/fixtures/cp_code/single.xml'
35
- savon.expects(:get_cp_codes).returns(fixture)
36
- end
37
-
38
- it 'returns a collection of cp codes' do
39
- AkamaiApi::CpCode.all.each { |o| o.should be_a AkamaiApi::CpCode }
40
- end
41
-
42
- it 'returns a collection with the correct size' do
43
- AkamaiApi::CpCode.all.count.should == 1
44
- end
45
- end
46
- end
47
- end