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.
- checksums.yaml +4 -4
- data/Guardfile +5 -15
- data/README.md +106 -36
- data/Thorfile +5 -0
- data/akamai_api.gemspec +6 -3
- data/bin/akamai_api +1 -2
- data/cassettes/akamai_api_ccu_arl_invalidate/invalid_credentials.yml +37 -0
- data/cassettes/akamai_api_ccu_arl_invalidate/invalid_item.yml +36 -0
- data/cassettes/akamai_api_ccu_arl_invalidate/multiple_items.yml +38 -0
- data/cassettes/akamai_api_ccu_arl_invalidate/single_item.yml +38 -0
- data/cassettes/akamai_api_ccu_arl_remove/invalid_credentials.yml +37 -0
- data/cassettes/akamai_api_ccu_arl_remove/invalid_item.yml +36 -0
- data/cassettes/akamai_api_ccu_arl_remove/multiple_items.yml +38 -0
- data/cassettes/akamai_api_ccu_arl_remove/single_item.yml +38 -0
- data/cassettes/akamai_api_ccu_cpcode_invalidate/invalid_credentials.yml +37 -0
- data/cassettes/akamai_api_ccu_cpcode_invalidate/invalid_item.yml +36 -0
- data/cassettes/akamai_api_ccu_cpcode_invalidate/multiple_items.yml +38 -0
- data/cassettes/akamai_api_ccu_cpcode_invalidate/single_item.yml +38 -0
- data/cassettes/akamai_api_ccu_cpcode_remove/invalid_credentials.yml +37 -0
- data/cassettes/akamai_api_ccu_cpcode_remove/invalid_item.yml +36 -0
- data/cassettes/akamai_api_ccu_cpcode_remove/multiple_items.yml +38 -0
- data/cassettes/akamai_api_ccu_cpcode_remove/single_item.yml +38 -0
- data/cassettes/akamai_api_ccu_purge_status/completed_request.yml +35 -0
- data/cassettes/akamai_api_ccu_purge_status/enqueued_request.yml +35 -0
- data/cassettes/akamai_api_ccu_purge_status/invalid_credentials.yml +35 -0
- data/cassettes/akamai_api_ccu_purge_status/not_found_request.yml +37 -0
- data/cassettes/akamai_api_ccu_status/invalid_credentials.yml +35 -0
- data/cassettes/akamai_api_ccu_status/valid_credentials.yml +34 -0
- data/cassettes/akamai_api_eccu_last_request/invalid_credentials.yml +68 -0
- data/cassettes/akamai_api_eccu_last_request/valid_credentials.yml +140 -0
- data/cassettes/akamai_api_eccu_publish/invalid_credentials.yml +73 -0
- data/cassettes/akamai_api_eccu_publish/invalid_domain.yml +60 -0
- data/cassettes/akamai_api_eccu_publish/successful.yml +126 -0
- data/cassettes/akamai_api_eccu_requests/invalid_credentials.yml +68 -0
- data/cassettes/akamai_api_eccu_requests/valid_credentials.yml +325 -0
- data/features/ccu_arl_invalidate.feature +83 -0
- data/features/ccu_arl_remove.feature +83 -0
- data/features/ccu_cpcode_invalidate.feature +83 -0
- data/features/ccu_cpcode_remove.feature +83 -0
- data/features/ccu_purge_status.feature +83 -0
- data/features/ccu_status.feature +31 -0
- data/features/eccu_last_request.feature +47 -0
- data/features/eccu_publish.feature +98 -0
- data/features/eccu_requests.feature +43 -0
- data/features/step_definitions/contain_multiple_times_steps.rb +3 -0
- data/features/support/env.rb +58 -0
- data/lib/akamai_api/ccu/purge/request.rb +76 -0
- data/lib/akamai_api/ccu/purge/response.rb +31 -0
- data/lib/akamai_api/ccu/purge.rb +5 -0
- data/lib/akamai_api/ccu/purge_status/not_found_response.rb +9 -0
- data/lib/akamai_api/ccu/purge_status/request.rb +32 -0
- data/lib/akamai_api/ccu/purge_status/response.rb +19 -0
- data/lib/akamai_api/ccu/purge_status/successful_response.rb +25 -0
- data/lib/akamai_api/ccu/purge_status.rb +10 -0
- data/lib/akamai_api/ccu/response.rb +18 -0
- data/lib/akamai_api/ccu/status/request.rb +23 -0
- data/lib/akamai_api/ccu/status/response.rb +11 -0
- data/lib/akamai_api/ccu/status.rb +2 -0
- data/lib/akamai_api/ccu.rb +14 -50
- data/lib/akamai_api/cli/app.rb +2 -2
- data/lib/akamai_api/cli/ccu/arl.rb +36 -0
- data/lib/akamai_api/cli/ccu/base.rb +18 -0
- data/lib/akamai_api/cli/ccu/cp_code.rb +39 -0
- data/lib/akamai_api/cli/ccu/purge_renderer.rb +49 -0
- data/lib/akamai_api/cli/ccu/status_renderer.rb +69 -0
- data/lib/akamai_api/cli/ccu.rb +5 -10
- data/lib/akamai_api/cli/eccu/entry_renderer.rb +63 -0
- data/lib/akamai_api/cli/eccu.rb +16 -14
- data/lib/akamai_api/cli.rb +7 -2
- data/lib/akamai_api/eccu_request.rb +19 -1
- data/lib/akamai_api/version.rb +1 -1
- data/lib/akamai_api.rb +3 -1
- data/spec/features/ccu/purge_request_spec.rb +94 -0
- data/spec/features/ccu/purge_status_request_spec.rb +31 -0
- data/spec/features/ccu/status_request_spec.rb +17 -0
- data/spec/fixtures/ccu/successful_purge.json +1 -0
- data/spec/lib/akamai_api/ccu/purge/request_spec.rb +124 -0
- data/spec/lib/akamai_api/ccu/purge/response_spec.rb +54 -0
- data/spec/lib/akamai_api/ccu/purge_status/not_found_response_spec.rb +41 -0
- data/spec/lib/akamai_api/ccu/purge_status/request_spec.rb +64 -0
- data/spec/lib/akamai_api/ccu/purge_status/successful_response_spec.rb +86 -0
- data/spec/lib/akamai_api/ccu/response_spec.rb +15 -0
- data/spec/lib/akamai_api/ccu/status/request_spec.rb +22 -0
- data/spec/lib/akamai_api/ccu/status/response_spec.rb +29 -0
- data/spec/lib/akamai_api/ccu_spec.rb +49 -61
- data/spec/lib/akamai_api/cli/ccu/status_renderer_spec.rb +36 -0
- data/spec/lib/akamai_api/eccu_request_spec.rb +5 -5
- data/spec/spec_helper.rb +21 -1
- metadata +163 -26
- data/lib/akamai_api/ccu_response.rb +0 -51
- data/lib/akamai_api/cli/ccu_arl.rb +0 -40
- data/lib/akamai_api/cli/ccu_cp_code.rb +0 -48
- data/lib/akamai_api/cli/template.rb +0 -36
- data/lib/akamai_api/cp_code.rb +0 -33
- data/spec/fixtures/ccu/successful_purge.xml +0 -15
- data/spec/fixtures/cp_code/collection.xml +0 -21
- data/spec/fixtures/cp_code/single.xml +0 -16
- data/spec/lib/akamai_api/cp_code_spec.rb +0 -47
- data/wsdls/cpcode.wsdl +0 -2765
@@ -0,0 +1,83 @@
|
|
1
|
+
Feature: akamai_api ccu purge status
|
2
|
+
In order to get the status of an Akamai CCU request
|
3
|
+
As a CLI user
|
4
|
+
|
5
|
+
@vcr
|
6
|
+
Scenario: invalid credentials
|
7
|
+
When I run `akamai_api ccu status 12345678-1234-5678-1234-123456789012 -u foo -p bar`
|
8
|
+
Then the output should contain:
|
9
|
+
"""
|
10
|
+
Your login credentials are invalid.
|
11
|
+
"""
|
12
|
+
|
13
|
+
@vcr
|
14
|
+
Scenario: completed request
|
15
|
+
When I run `akamai_api ccu status /ccu/v2/purges/12345678-1234-5678-1234-123456789012`
|
16
|
+
Then the output should contain:
|
17
|
+
"""
|
18
|
+
Purge request has been successfully completed:
|
19
|
+
"""
|
20
|
+
And the output should contain:
|
21
|
+
"""
|
22
|
+
* Result: 200 - Done
|
23
|
+
"""
|
24
|
+
And the output should contain:
|
25
|
+
"""
|
26
|
+
* Purge ID: 12345678-1234-5678-1234-123456789012 | Support ID: 12345678901234567890-123456789
|
27
|
+
"""
|
28
|
+
And the output should contain:
|
29
|
+
"""
|
30
|
+
* Submitted by: test1 on 2014-05-20 08:19:21 UTC
|
31
|
+
"""
|
32
|
+
And the output should contain:
|
33
|
+
"""
|
34
|
+
* Completed on: 2014-05-20 08:22:20 UTC
|
35
|
+
"""
|
36
|
+
|
37
|
+
@vcr
|
38
|
+
Scenario: enqueued request
|
39
|
+
When I run `akamai_api ccu status ccu/v2/purges/12345678-1234-5678-1234-123456789012`
|
40
|
+
Then the output should contain:
|
41
|
+
"""
|
42
|
+
Purge request is currently enqueued:
|
43
|
+
"""
|
44
|
+
And the output should contain:
|
45
|
+
"""
|
46
|
+
Result: 200 - In-Progress
|
47
|
+
"""
|
48
|
+
And the output should contain:
|
49
|
+
"""
|
50
|
+
* Purge ID: 12345678-1234-5678-1234-123456789012 | Support ID: 12345678901234567890-123456789
|
51
|
+
"""
|
52
|
+
And the output should contain:
|
53
|
+
"""
|
54
|
+
* Submitted by: test1 on 2014-05-20 08:19:21 UTC
|
55
|
+
"""
|
56
|
+
And the output should contain:
|
57
|
+
"""
|
58
|
+
* Time to wait before next check: 60 secs.
|
59
|
+
"""
|
60
|
+
And the output should not contain:
|
61
|
+
"""
|
62
|
+
* Completed on
|
63
|
+
"""
|
64
|
+
|
65
|
+
@vcr
|
66
|
+
Scenario: not found request
|
67
|
+
When I run `akamai_api ccu status foobarbaz`
|
68
|
+
Then the output should contain:
|
69
|
+
"""
|
70
|
+
No purge request found using /ccu/v2/purges/foobarbaz:
|
71
|
+
"""
|
72
|
+
And the output should contain:
|
73
|
+
"""
|
74
|
+
Result: 200 - Please note that it can take up to a minute for the status of a recently submitted request to become visible.
|
75
|
+
"""
|
76
|
+
And the output should contain:
|
77
|
+
"""
|
78
|
+
* Purge ID: foobarbaz | Support ID: 12345678901234567890-123456789
|
79
|
+
"""
|
80
|
+
And the output should contain:
|
81
|
+
"""
|
82
|
+
* Time to wait before next check: 60 secs.
|
83
|
+
"""
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Feature: akamai_api ccu status
|
2
|
+
In order to get the Akamai CCU queue status
|
3
|
+
As a CLI user
|
4
|
+
|
5
|
+
@vcr
|
6
|
+
Scenario: invalid credentials
|
7
|
+
When I run `akamai_api ccu status -u foo -p bar`
|
8
|
+
Then the output should contain:
|
9
|
+
"""
|
10
|
+
Your login credentials are invalid.
|
11
|
+
"""
|
12
|
+
|
13
|
+
@vcr
|
14
|
+
Scenario: valid credentials
|
15
|
+
When I run `akamai_api ccu status`
|
16
|
+
Then the output should contain:
|
17
|
+
"""
|
18
|
+
Akamai CCU Queue Status
|
19
|
+
"""
|
20
|
+
And the output should contain:
|
21
|
+
"""
|
22
|
+
* Result: 200 - The queue may take a minute to reflect new or removed requests.
|
23
|
+
"""
|
24
|
+
And the output should contain:
|
25
|
+
"""
|
26
|
+
* Support ID: 12345678901234567890-123456789
|
27
|
+
"""
|
28
|
+
And the output should contain:
|
29
|
+
"""
|
30
|
+
* Queue Length: 0
|
31
|
+
"""
|
@@ -0,0 +1,47 @@
|
|
1
|
+
Feature: akamai_api eccu last_request
|
2
|
+
In order to get the last request made through ECCU
|
3
|
+
As a CLI user
|
4
|
+
|
5
|
+
@vcr
|
6
|
+
Scenario: invalid credentials
|
7
|
+
When I run `akamai_api eccu last_request -u foo -p bar`
|
8
|
+
Then the output should contain:
|
9
|
+
"""
|
10
|
+
Your login credentials are invalid.
|
11
|
+
"""
|
12
|
+
|
13
|
+
@vcr
|
14
|
+
Scenario: valid credentials
|
15
|
+
When I run `akamai_api eccu last_request`
|
16
|
+
Then the output should contain:
|
17
|
+
"""
|
18
|
+
* Code : 115942214\n
|
19
|
+
"""
|
20
|
+
And the output should contain:
|
21
|
+
"""
|
22
|
+
* Status : 4000 - File successfully deployed to Akamai network (Succeeded)
|
23
|
+
"""
|
24
|
+
And the output should contain:
|
25
|
+
"""
|
26
|
+
2014-05-19T16:27:34.512Z
|
27
|
+
"""
|
28
|
+
And the output should contain:
|
29
|
+
"""
|
30
|
+
* Property: foo.com (hostheader)
|
31
|
+
"""
|
32
|
+
And the output should contain:
|
33
|
+
"""
|
34
|
+
with exact match
|
35
|
+
"""
|
36
|
+
And the output should contain:
|
37
|
+
"""
|
38
|
+
* Notes : ECCU Request using EdgeControl
|
39
|
+
"""
|
40
|
+
And the output should contain:
|
41
|
+
"""
|
42
|
+
* Email : guest@mikamai.com
|
43
|
+
"""
|
44
|
+
And the output should contain:
|
45
|
+
"""
|
46
|
+
* Uploaded by test1 on 2014-05-19T15:30:13.512Z
|
47
|
+
"""
|
@@ -0,0 +1,98 @@
|
|
1
|
+
Feature: akamai_api eccu publish
|
2
|
+
In order to publish a purge request via ECCU
|
3
|
+
As a CLI user
|
4
|
+
|
5
|
+
@vcr
|
6
|
+
Scenario: invalid credentials
|
7
|
+
Given a file named "publish.xml" with:
|
8
|
+
"""
|
9
|
+
<?xml version="1.0"?>
|
10
|
+
<eccu>
|
11
|
+
<match:recursive-dirs value="foo" >
|
12
|
+
<match:recursive-dirs value="bar" >
|
13
|
+
<match:recursive-dirs value="baz.jpg" >
|
14
|
+
<revalidate>now</revalidate>
|
15
|
+
</match:recursive-dirs>
|
16
|
+
</match:recursive-dirs>
|
17
|
+
</match:recursive-dirs>
|
18
|
+
</eccu>
|
19
|
+
"""
|
20
|
+
When I run `akamai_api eccu publish_xml ./publish.xml foo.com -u foo -p bar`
|
21
|
+
Then the output should contain:
|
22
|
+
"""
|
23
|
+
Your login credentials are invalid.
|
24
|
+
"""
|
25
|
+
|
26
|
+
@vcr
|
27
|
+
Scenario: invalid domain
|
28
|
+
Given a file named "publish.xml" with:
|
29
|
+
"""
|
30
|
+
<?xml version="1.0"?>
|
31
|
+
<eccu>
|
32
|
+
<match:recursive-dirs value="foo" >
|
33
|
+
<match:recursive-dirs value="bar" >
|
34
|
+
<match:recursive-dirs value="baz.jpg" >
|
35
|
+
<revalidate>now</revalidate>
|
36
|
+
</match:recursive-dirs>
|
37
|
+
</match:recursive-dirs>
|
38
|
+
</match:recursive-dirs>
|
39
|
+
</eccu>
|
40
|
+
"""
|
41
|
+
When I run `akamai_api eccu publish_xml ./publish.xml john.smith.com`
|
42
|
+
Then the output should contain:
|
43
|
+
"""
|
44
|
+
ECCU validation failed: You are not authorized to specify this digital property
|
45
|
+
"""
|
46
|
+
|
47
|
+
@vcr
|
48
|
+
Scenario: successful
|
49
|
+
Given a file named "publish.xml" with:
|
50
|
+
"""
|
51
|
+
<?xml version="1.0"?>
|
52
|
+
<eccu>
|
53
|
+
<match:recursive-dirs value="foo" >
|
54
|
+
<match:recursive-dirs value="bar" >
|
55
|
+
<match:recursive-dirs value="baz.jpg" >
|
56
|
+
<revalidate>now</revalidate>
|
57
|
+
</match:recursive-dirs>
|
58
|
+
</match:recursive-dirs>
|
59
|
+
</match:recursive-dirs>
|
60
|
+
</eccu>
|
61
|
+
"""
|
62
|
+
When I run `akamai_api eccu publish_xml ./publish.xml foo.com`
|
63
|
+
Then the output should contain:
|
64
|
+
"""
|
65
|
+
Request correctly published
|
66
|
+
"""
|
67
|
+
And the output should contain:
|
68
|
+
"""
|
69
|
+
* Code : 116073578
|
70
|
+
"""
|
71
|
+
And the output should contain:
|
72
|
+
"""
|
73
|
+
* Status : 1000
|
74
|
+
"""
|
75
|
+
And the output should contain:
|
76
|
+
"""
|
77
|
+
2014-05-20T16:49:29.026Z
|
78
|
+
"""
|
79
|
+
And the output should contain:
|
80
|
+
"""
|
81
|
+
* Property: foo.com (hostheader)
|
82
|
+
"""
|
83
|
+
And the output should contain:
|
84
|
+
"""
|
85
|
+
with exact match
|
86
|
+
"""
|
87
|
+
And the output should contain:
|
88
|
+
"""
|
89
|
+
* Notes : ECCU Request using AkamaiApi gem
|
90
|
+
"""
|
91
|
+
And the output should contain:
|
92
|
+
"""
|
93
|
+
* Uploaded by test1 on 2014-05-20T16:49:29.026Z
|
94
|
+
"""
|
95
|
+
And the output should contain:
|
96
|
+
"""
|
97
|
+
Content:
|
98
|
+
"""
|
@@ -0,0 +1,43 @@
|
|
1
|
+
Feature: akamai_api eccu requests
|
2
|
+
In order to get the list of the last requests made through ECCU
|
3
|
+
As a CLI user
|
4
|
+
|
5
|
+
@vcr
|
6
|
+
Scenario: invalid credentials
|
7
|
+
When I run `akamai_api eccu requests -u foo -p bar`
|
8
|
+
Then the output should contain:
|
9
|
+
"""
|
10
|
+
Your login credentials are invalid.
|
11
|
+
"""
|
12
|
+
|
13
|
+
@vcr
|
14
|
+
Scenario: valid credentials
|
15
|
+
When I run `akamai_api eccu requests`
|
16
|
+
Then the output should contain 4 times:
|
17
|
+
"""
|
18
|
+
* Status
|
19
|
+
"""
|
20
|
+
Then the output should contain:
|
21
|
+
"""
|
22
|
+
* Code : 112714868
|
23
|
+
"""
|
24
|
+
And the output should contain 4 times:
|
25
|
+
"""
|
26
|
+
* Status : 4000 - File successfully deployed to Akamai network (Succeeded)
|
27
|
+
"""
|
28
|
+
And the output should contain 3 times:
|
29
|
+
"""
|
30
|
+
* Property: foo.com (hostheader)
|
31
|
+
"""
|
32
|
+
And the output should contain 4 times:
|
33
|
+
"""
|
34
|
+
with exact match
|
35
|
+
"""
|
36
|
+
And the output should contain 4 times:
|
37
|
+
"""
|
38
|
+
* Notes : ECCU Request using EdgeControl
|
39
|
+
"""
|
40
|
+
And the output should contain 4 times:
|
41
|
+
"""
|
42
|
+
* Email : guest@mikamai.com
|
43
|
+
"""
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'akamai_api'
|
2
|
+
require 'akamai_api/cli'
|
3
|
+
require 'aruba'
|
4
|
+
require 'aruba/cucumber'
|
5
|
+
require 'aruba/in_process'
|
6
|
+
require 'vcr'
|
7
|
+
require 'webmock'
|
8
|
+
|
9
|
+
require File.expand_path '../../../spec/auth', __FILE__
|
10
|
+
ENV['AKAMAI_USERNAME'], ENV['AKAMAI_PASSWORD'] = AkamaiApi.config[:auth]
|
11
|
+
|
12
|
+
VCR.cucumber_tags do |t|
|
13
|
+
t.tag '@vcr', use_scenario_name: true
|
14
|
+
end
|
15
|
+
|
16
|
+
VCR.configure do |c|
|
17
|
+
c.hook_into :webmock
|
18
|
+
c.cassette_library_dir = 'cassettes'
|
19
|
+
c.default_cassette_options = {
|
20
|
+
record: :once
|
21
|
+
}
|
22
|
+
c.after_http_request do |request|
|
23
|
+
request.uri.gsub! ENV['AKAMAI_USERNAME'], 'USERNAME'
|
24
|
+
request.uri.gsub! ENV['AKAMAI_PASSWORD'], 'PASSWORD'
|
25
|
+
end
|
26
|
+
c.before_playback do |i|
|
27
|
+
i.request.uri.gsub! 'USERNAME', ENV['AKAMAI_USERNAME']
|
28
|
+
i.request.uri.gsub! 'PASSWORD', ENV['AKAMAI_PASSWORD']
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class VcrFriendlyCLI
|
33
|
+
def initialize(argv, stdin=STDIN, stdout=STDOUT, stderr=STDERR, kernel=Kernel)
|
34
|
+
@argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
|
35
|
+
end
|
36
|
+
|
37
|
+
def execute!
|
38
|
+
$stdin = @stdin
|
39
|
+
$stdout = @stdout
|
40
|
+
@kernel.exit AkamaiApi::Cli::App.start(@argv.dup)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
Before do
|
45
|
+
@aruba_timeout_seconds = 30
|
46
|
+
end
|
47
|
+
|
48
|
+
Before('@vcr') do
|
49
|
+
Aruba::InProcess.main_class = VcrFriendlyCLI
|
50
|
+
Aruba.process = Aruba::InProcess
|
51
|
+
end
|
52
|
+
|
53
|
+
After('@vcr') do
|
54
|
+
Aruba.process = Aruba::SpawnProcess
|
55
|
+
VCR.eject_cassette
|
56
|
+
$stdin = STDIN
|
57
|
+
$stdout = STDOUT
|
58
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module AkamaiApi::Ccu::Purge
|
2
|
+
class Request
|
3
|
+
include HTTParty
|
4
|
+
format :json
|
5
|
+
base_uri 'https://api.ccu.akamai.com/ccu/v2/queues/default'
|
6
|
+
headers 'Content-Type' => 'application/json'
|
7
|
+
|
8
|
+
attr_reader :type, :action, :domain
|
9
|
+
|
10
|
+
def initialize action = 'remove', type = 'arl', args = {}
|
11
|
+
self.action = action
|
12
|
+
self.type = type
|
13
|
+
self.domain = args[:domain] || 'production'
|
14
|
+
end
|
15
|
+
|
16
|
+
def action= value
|
17
|
+
raise_unrecognized_action(value) unless valid_action?(value)
|
18
|
+
@action = value
|
19
|
+
end
|
20
|
+
|
21
|
+
def type= value
|
22
|
+
raise_unrecognized_type(value) unless valid_type?(value)
|
23
|
+
@type = value
|
24
|
+
end
|
25
|
+
|
26
|
+
def domain= value
|
27
|
+
raise_unrecognized_domain(value) unless valid_domain?(value)
|
28
|
+
@domain = value
|
29
|
+
end
|
30
|
+
|
31
|
+
def execute *items
|
32
|
+
items = Array.wrap(items.first) if items.length == 1
|
33
|
+
response = self.class.post('/', basic_auth: auth, body: request_body(items))
|
34
|
+
parse_response response
|
35
|
+
end
|
36
|
+
|
37
|
+
def auth
|
38
|
+
AkamaiApi::Ccu.auth
|
39
|
+
end
|
40
|
+
|
41
|
+
def request_body items
|
42
|
+
{ type: type, action: action, domain: domain, objects: items }.to_json
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def parse_response response
|
48
|
+
raise ::AkamaiApi::Unauthorized if response.code == 401
|
49
|
+
Response.new response.parsed_response
|
50
|
+
end
|
51
|
+
|
52
|
+
def raise_unrecognized_action bad_action
|
53
|
+
raise ::AkamaiApi::Ccu::UnrecognizedOption, "Unknown action '#{bad_action}' (allowed values: invalidate, remove)"
|
54
|
+
end
|
55
|
+
|
56
|
+
def raise_unrecognized_type bad_type
|
57
|
+
raise ::AkamaiApi::Ccu::UnrecognizedOption, "Unknown type '#{bad_type}' (allowed values: arl, cpcode)"
|
58
|
+
end
|
59
|
+
|
60
|
+
def raise_unrecognized_domain bad_domain
|
61
|
+
raise ::AkamaiApi::Ccu::UnrecognizedOption, "Unknown domain '#{bad_domain}' (allowed_values: production, staging)"
|
62
|
+
end
|
63
|
+
|
64
|
+
def valid_action? action
|
65
|
+
%w(invalidate remove).include? action.to_s
|
66
|
+
end
|
67
|
+
|
68
|
+
def valid_type? type
|
69
|
+
%w(arl cpcode).include? type.to_s
|
70
|
+
end
|
71
|
+
|
72
|
+
def valid_domain? domain
|
73
|
+
%w(production staging).include? domain.to_s
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module AkamaiApi::Ccu::Purge
|
2
|
+
class Response < ::AkamaiApi::Ccu::Response
|
3
|
+
def described_by
|
4
|
+
raw['describedBy']
|
5
|
+
end
|
6
|
+
|
7
|
+
def title
|
8
|
+
raw['title']
|
9
|
+
end
|
10
|
+
|
11
|
+
def time_to_wait
|
12
|
+
raw['pingAfterSeconds']
|
13
|
+
end
|
14
|
+
|
15
|
+
def purge_id
|
16
|
+
raw['purgeId']
|
17
|
+
end
|
18
|
+
|
19
|
+
def message
|
20
|
+
raw['detail']
|
21
|
+
end
|
22
|
+
|
23
|
+
def estimated_time
|
24
|
+
raw['estimatedSeconds']
|
25
|
+
end
|
26
|
+
|
27
|
+
def uri
|
28
|
+
raw['progressUri']
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module AkamaiApi::Ccu::PurgeStatus
|
2
|
+
class Request
|
3
|
+
include HTTParty
|
4
|
+
format :json
|
5
|
+
base_uri 'https://api.ccu.akamai.com'
|
6
|
+
|
7
|
+
def execute progress_uri
|
8
|
+
response = self.class.get normalize_progress_uri(progress_uri), basic_auth: auth
|
9
|
+
parse_response response
|
10
|
+
end
|
11
|
+
|
12
|
+
def auth
|
13
|
+
AkamaiApi::Ccu.auth
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def parse_response response
|
19
|
+
raise AkamaiApi::Unauthorized if response.code == 401
|
20
|
+
AkamaiApi::Ccu::PurgeStatus.build_response response.parsed_response
|
21
|
+
end
|
22
|
+
|
23
|
+
def normalize_progress_uri progress_uri
|
24
|
+
progress_uri = "/#{progress_uri}" unless progress_uri =~ /^\//
|
25
|
+
if progress_uri =~ /\/ccu\/v2\/purges\//
|
26
|
+
progress_uri
|
27
|
+
else
|
28
|
+
"/ccu/v2/purges#{progress_uri}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module AkamaiApi::Ccu::PurgeStatus
|
2
|
+
class Response < ::AkamaiApi::Ccu::Response
|
3
|
+
def progress_uri
|
4
|
+
raw['progressUri']
|
5
|
+
end
|
6
|
+
|
7
|
+
def purge_id
|
8
|
+
raw['purgeId']
|
9
|
+
end
|
10
|
+
|
11
|
+
def status
|
12
|
+
raw['purgeStatus']
|
13
|
+
end
|
14
|
+
|
15
|
+
def time_to_wait
|
16
|
+
raw['pingAfterSeconds']
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path '../response', __FILE__
|
2
|
+
|
3
|
+
module AkamaiApi::Ccu::PurgeStatus
|
4
|
+
class SuccessfulResponse < Response
|
5
|
+
def estimated_time
|
6
|
+
raw['originalEstimatedSeconds']
|
7
|
+
end
|
8
|
+
|
9
|
+
def queue_length
|
10
|
+
raw['originalQueueLength']
|
11
|
+
end
|
12
|
+
|
13
|
+
def completed_at
|
14
|
+
raw['completionTime'] && Time.iso8601(raw['completionTime'])
|
15
|
+
end
|
16
|
+
|
17
|
+
def submitted_by
|
18
|
+
raw['submittedBy']
|
19
|
+
end
|
20
|
+
|
21
|
+
def submitted_at
|
22
|
+
raw['submissionTime'] && Time.iso8601(raw['submissionTime'])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module AkamaiApi::Ccu::PurgeStatus
|
2
|
+
def self.build_response parsed_response
|
3
|
+
response_class = parsed_response['submittedBy'] ? SuccessfulResponse : NotFoundResponse
|
4
|
+
response_class.new parsed_response
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
require File.expand_path '../purge_status/request', __FILE__
|
9
|
+
require File.expand_path '../purge_status/successful_response', __FILE__
|
10
|
+
require File.expand_path '../purge_status/not_found_response', __FILE__
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module AkamaiApi::Ccu::Status
|
2
|
+
class Request
|
3
|
+
include HTTParty
|
4
|
+
format :json
|
5
|
+
base_uri 'https://api.ccu.akamai.com/ccu/v2/queues/default'
|
6
|
+
|
7
|
+
def execute
|
8
|
+
response = self.class.get('/', basic_auth: auth)
|
9
|
+
parse_response response
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def auth
|
15
|
+
AkamaiApi::Ccu.auth
|
16
|
+
end
|
17
|
+
|
18
|
+
def parse_response response
|
19
|
+
raise AkamaiApi::Unauthorized if response.code == 401
|
20
|
+
AkamaiApi::Ccu::Status::Response.new response.parsed_response
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|