akamai_api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +189 -0
- data/Thorfile +30 -0
- data/akamai_api.gemspec +27 -0
- data/bin/akamai_api +22 -0
- data/lib/akamai_api/ccu.rb +71 -0
- data/lib/akamai_api/ccu_response.rb +51 -0
- data/lib/akamai_api/cli/ccu.rb +11 -0
- data/lib/akamai_api/cli/ccu_arl.rb +40 -0
- data/lib/akamai_api/cli/ccu_cp_code.rb +48 -0
- data/lib/akamai_api/cli/command.rb +24 -0
- data/lib/akamai_api/cli/eccu.rb +55 -0
- data/lib/akamai_api/cli/template.rb +36 -0
- data/lib/akamai_api/cli.rb +3 -0
- data/lib/akamai_api/cp_code.rb +26 -0
- data/lib/akamai_api/eccu_request.rb +137 -0
- data/lib/akamai_api/soap_body.rb +52 -0
- data/lib/akamai_api/version.rb +3 -0
- data/lib/akamai_api.rb +9 -0
- data/spec/fixtures/delete/success.xml +8 -0
- data/spec/fixtures/eccu_request.xml +10 -0
- data/spec/fixtures/get_cp_codes/sample.xml +21 -0
- data/spec/fixtures/get_ids/success.xml +11 -0
- data/spec/fixtures/get_info/success.xml +25 -0
- data/spec/fixtures/set_notes/success.xml +8 -0
- data/spec/fixtures/set_status_change_email/success.xml +8 -0
- data/spec/fixtures/upload/fault.xml +13 -0
- data/spec/fixtures/upload/success.xml +8 -0
- data/spec/fixtures/wsdl:purge_request/success.xml +15 -0
- data/spec/lib/akamai_api/ccu_spec.rb +115 -0
- data/spec/lib/akamai_api/cp_code_spec.rb +25 -0
- data/spec/lib/akamai_api/eccu_request_spec.rb +216 -0
- data/spec/lib/akamai_api/soap_body_spec.rb +51 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/support/savon_tester.rb +18 -0
- data/wsdls/ccuapi.wsdl +82 -0
- metadata +197 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
module AkamaiApi
|
2
|
+
class CpCode
|
3
|
+
extend Savon::Model
|
4
|
+
|
5
|
+
document 'https://control.akamai.com/nmrws/services/SiteAcceleratorReportService?wsdl'
|
6
|
+
|
7
|
+
attr_accessor :code, :description, :service
|
8
|
+
|
9
|
+
def initialize attributes
|
10
|
+
attributes.each do |key, value|
|
11
|
+
send "#{key}=", value
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.all
|
16
|
+
basic_auth *AkamaiApi.config[:auth]
|
17
|
+
client.request('getCPCodes').body[:multi_ref].map do |hash|
|
18
|
+
new({
|
19
|
+
:code => hash[:cpcode],
|
20
|
+
:description => hash[:description],
|
21
|
+
:service => hash[:service],
|
22
|
+
})
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
module AkamaiApi
|
2
|
+
class EccuRequest
|
3
|
+
extend Savon::Model
|
4
|
+
|
5
|
+
document 'https://control.akamai.com/webservices/services/PublishECCU?wsdl'
|
6
|
+
|
7
|
+
attr_accessor :file, :status, :code, :notes, :property, :email, :upload_date, :uploaded_by, :version_string
|
8
|
+
|
9
|
+
def initialize attributes = {}
|
10
|
+
attributes.each do |key, value|
|
11
|
+
send "#{key}=", value
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def update_notes! notes
|
16
|
+
code = self.code.to_i
|
17
|
+
resp = client.request 'setNotes' do
|
18
|
+
SoapBody.new(soap) do
|
19
|
+
integer :fileId, code
|
20
|
+
string :notes, notes
|
21
|
+
end
|
22
|
+
end
|
23
|
+
self.notes = notes
|
24
|
+
resp.body[:set_notes_response][:success]
|
25
|
+
end
|
26
|
+
|
27
|
+
def update_email! email
|
28
|
+
code = self.code.to_i
|
29
|
+
resp = client.request 'setStatusChangeEmail' do
|
30
|
+
SoapBody.new(soap) do
|
31
|
+
integer :fileId, code
|
32
|
+
string :statusChangeEmail, email
|
33
|
+
end
|
34
|
+
end
|
35
|
+
self.email = email
|
36
|
+
resp.body[:set_status_change_email_response][:success]
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy
|
40
|
+
code = self.code.to_i
|
41
|
+
resp = client.request 'delete' do |soap|
|
42
|
+
SoapBody.new(soap) do
|
43
|
+
integer :fileId, code
|
44
|
+
end
|
45
|
+
end
|
46
|
+
resp.body[:delete_response][:success]
|
47
|
+
end
|
48
|
+
|
49
|
+
class << self
|
50
|
+
def all_ids
|
51
|
+
basic_auth *AkamaiApi.config[:auth]
|
52
|
+
client.request('getIds').body[:get_ids_response][:file_ids][:file_ids]
|
53
|
+
end
|
54
|
+
|
55
|
+
def all args = {}
|
56
|
+
all_ids.map { |v| EccuRequest.find v, args }
|
57
|
+
end
|
58
|
+
|
59
|
+
def last args = {}
|
60
|
+
find all_ids.last, args
|
61
|
+
end
|
62
|
+
|
63
|
+
def first args = {}
|
64
|
+
find all_ids.first, args
|
65
|
+
end
|
66
|
+
|
67
|
+
def find code, args = {}
|
68
|
+
basic_auth *AkamaiApi.config[:auth]
|
69
|
+
resp = client.request 'getInfo' do
|
70
|
+
SoapBody.new(soap) do
|
71
|
+
integer :fileId, code.to_i
|
72
|
+
boolean :retrieveContents, args[:verbose] == true
|
73
|
+
end
|
74
|
+
end
|
75
|
+
resp = resp[:get_info_response][:eccu_info]
|
76
|
+
EccuRequest.new({
|
77
|
+
:file => {
|
78
|
+
:content => Base64.decode64(get_if_kind(resp[:contents], String) || ''),
|
79
|
+
:file_size => resp[:file_size].to_i,
|
80
|
+
:file_name => get_if_kind(resp[:filename], String),
|
81
|
+
:md5_digest => get_if_kind(resp[:md5_digest], String)
|
82
|
+
},
|
83
|
+
:status => {
|
84
|
+
:extended => get_if_kind(resp[:extended_status_message], String),
|
85
|
+
:code => resp[:status_code].to_i,
|
86
|
+
:message => get_if_kind(resp[:status_message], String),
|
87
|
+
:update_date => get_if_kind(resp[:status_update_date], String)
|
88
|
+
},
|
89
|
+
:code => resp[:file_id],
|
90
|
+
:notes => get_if_kind(resp[:notes], String),
|
91
|
+
:property => {
|
92
|
+
:name => get_if_kind(resp[:property_name], String),
|
93
|
+
:exact_match => (resp[:property_name_exact_match] == true),
|
94
|
+
:type => get_if_kind(resp[:property_type], String)
|
95
|
+
},
|
96
|
+
:email => get_if_kind(resp[:status_change_email], String),
|
97
|
+
:upload_date => get_if_kind(resp[:upload_date], String),
|
98
|
+
:uploaded_by => get_if_kind(resp[:uploaded_by], String),
|
99
|
+
:version_string => get_if_kind(resp[:version_string], String)
|
100
|
+
})
|
101
|
+
end
|
102
|
+
|
103
|
+
def publish_file property, file_name, args = {}
|
104
|
+
args[:file_name] = file_name
|
105
|
+
publish property, File.read(file_name), args
|
106
|
+
end
|
107
|
+
|
108
|
+
def publish property, content, args = {}
|
109
|
+
basic_auth *AkamaiApi.config[:auth]
|
110
|
+
resp = client.request 'upload' do
|
111
|
+
SoapBody.new(soap) do
|
112
|
+
string :filename, args[:file_name] || ''
|
113
|
+
text :contents, content
|
114
|
+
string :notes, args[:notes] || 'ECCU Request using AkamaiApi gem'
|
115
|
+
string :versionString, args[:version] || ''
|
116
|
+
if args[:emails]
|
117
|
+
string :statusChangeEmail, Array.wrap(args[:emails]).join(' ')
|
118
|
+
end
|
119
|
+
string :propertyName, property
|
120
|
+
string :propertyType, args[:property_type] || 'hostheader'
|
121
|
+
boolean :propertyNameExactMatch, args[:property_exact_match].nil? && true || args[:property_exact_match]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
resp.body[:upload_response][:file_id].to_i
|
125
|
+
end
|
126
|
+
|
127
|
+
private
|
128
|
+
|
129
|
+
# This method is used because, for nil values, savon will respond with an hash containing all other attributes.
|
130
|
+
# If we check that the expected type is matched, we can
|
131
|
+
# prevent to retrieve wrong values
|
132
|
+
def get_if_kind value, kind
|
133
|
+
value.kind_of?(kind) && value || nil
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module AkamaiApi
|
2
|
+
class SoapBody
|
3
|
+
attr_accessor :soap
|
4
|
+
|
5
|
+
def initialize soap, &block
|
6
|
+
self.soap = soap
|
7
|
+
self.soap.namespaces['xmlns:soapenc'] = 'http://schemas.xmlsoap.org/soap/encoding/'
|
8
|
+
instance_eval &block if block
|
9
|
+
end
|
10
|
+
|
11
|
+
def body
|
12
|
+
soap.body ||= {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def body_attributes
|
16
|
+
body[:attributes!] ||= {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def text name, value
|
20
|
+
name = name.to_sym
|
21
|
+
body[name] = Base64.encode64 value
|
22
|
+
body_attributes[name] = { 'xsi:type' => 'xsd:base64Binary' }
|
23
|
+
end
|
24
|
+
|
25
|
+
def boolean name, value
|
26
|
+
name = name.to_sym
|
27
|
+
body[name] = value
|
28
|
+
body_attributes[name] = { 'xsi:type' => 'xsd:boolean' }
|
29
|
+
end
|
30
|
+
|
31
|
+
def integer name, value
|
32
|
+
name = name.to_sym
|
33
|
+
body[name] = value
|
34
|
+
body_attributes[name] = { 'xsi:type' => 'xsd:int' }
|
35
|
+
end
|
36
|
+
|
37
|
+
def string name, value
|
38
|
+
name = name.to_sym
|
39
|
+
body[name] = value
|
40
|
+
body_attributes[name] = { 'xsi:type' => 'xsd:string' }
|
41
|
+
end
|
42
|
+
|
43
|
+
def array name, values
|
44
|
+
name = name.to_sym
|
45
|
+
body[name] = { 'item' => values }
|
46
|
+
body_attributes[name] = {
|
47
|
+
'soapenc:arrayType' => "xsd:string[#{values.length}]",
|
48
|
+
'xsi:type' => 'wsdl:ArrayOfString'
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/akamai_api.rb
ADDED
@@ -0,0 +1,8 @@
|
|
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
|
+
<deleteResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
5
|
+
<success xsi:type="xsd:boolean">true</success>
|
6
|
+
</deleteResponse>
|
7
|
+
</soapenv:Body>
|
8
|
+
</soapenv:Envelope>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<eccu>
|
3
|
+
<match:recursive-dirs value="foo" >
|
4
|
+
<match:recursive-dirs value="bar" >
|
5
|
+
<match:recursive-dirs value="baz.jpg" >
|
6
|
+
<revalidate>now</revalidate>
|
7
|
+
</match:recursive-dirs>
|
8
|
+
</match:recursive-dirs>
|
9
|
+
</match:recursive-dirs>
|
10
|
+
</eccu>
|
@@ -0,0 +1,21 @@
|
|
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>
|
@@ -0,0 +1,11 @@
|
|
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
|
+
<getIdsResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
5
|
+
<fileIds soapenc:arrayType="xsd:int[10]" xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
|
6
|
+
<fileIds xsi:type="xsd:int">42994282</fileIds>
|
7
|
+
<fileIds xsi:type="xsd:int">43000154</fileIds>
|
8
|
+
</fileIds>
|
9
|
+
</getIdsResponse>
|
10
|
+
</soapenv:Body>
|
11
|
+
</soapenv:Envelope>
|
@@ -0,0 +1,25 @@
|
|
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
|
+
<getInfoResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
5
|
+
<EccuInfo xsi:type="ns1:EccuInfo" xmlns:ns1="https://control.akamai.com/Publish.xsd">
|
6
|
+
<contents xsi:type="xsd:base64Binary">PGVjY3U+XG4gIDxyZXZhbGlkYXRlPm5vdzwvcmV2YWxpZGF0ZT5cbjwvZWNj\ndT5cbg==</contents>
|
7
|
+
<extendedStatusMessage xsi:type="xsd:string">File successfully deployed to Akamai network (Succeeded)</extendedStatusMessage>
|
8
|
+
<fileId xsi:type="xsd:int">1234567</fileId>
|
9
|
+
<fileSize xsi:type="xsd:int">127</fileSize>
|
10
|
+
<filename xsi:type="xsd:string" xsi:nil="true"/>
|
11
|
+
<notes xsi:type="xsd:string">ECCU Request using EdgeControl</notes>
|
12
|
+
<propertyName xsi:type="xsd:string">www.example.com</propertyName>
|
13
|
+
<propertyNameExactMatch xsi:type="xsd:boolean">true</propertyNameExactMatch>
|
14
|
+
<propertyType xsi:type="xsd:string">hostheader</propertyType>
|
15
|
+
<statusChangeEmail xsi:type="xsd:string">foo@example.com</statusChangeEmail>
|
16
|
+
<statusCode xsi:type="xsd:int">4000</statusCode>
|
17
|
+
<statusMessage xsi:type="xsd:string">File successfully deployed to Akamai's network</statusMessage>
|
18
|
+
<statusUpdateDate xsi:type="xsd:dateTime">2012-09-20T07:58:10.936Z</statusUpdateDate>
|
19
|
+
<uploadDate xsi:type="xsd:dateTime">2012-09-20T07:17:25.936Z</uploadDate>
|
20
|
+
<uploadedBy xsi:type="xsd:string">foo</uploadedBy>
|
21
|
+
<versionString xsi:type="xsd:string" xsi:nil="true"/>
|
22
|
+
</EccuInfo>
|
23
|
+
</getInfoResponse>
|
24
|
+
</soapenv:Body>
|
25
|
+
</soapenv:Envelope>
|
@@ -0,0 +1,8 @@
|
|
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
|
+
<setNotesResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
5
|
+
<success xsi:type="xsd:boolean">true</success>
|
6
|
+
</setNotesResponse>
|
7
|
+
</soapenv:Body>
|
8
|
+
</soapenv:Envelope>
|
@@ -0,0 +1,8 @@
|
|
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
|
+
<setStatusChangeEmailResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
5
|
+
<success xsi:type="xsd:boolean">true</success>
|
6
|
+
</setStatusChangeEmailResponse>
|
7
|
+
</soapenv:Body>
|
8
|
+
</soapenv:Envelope>
|
@@ -0,0 +1,13 @@
|
|
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
|
+
<soapenv:Fault>
|
5
|
+
<faultcode>soapenv:Server.generalException</faultcode>
|
6
|
+
<faultstring>ECCU validation failed: You are not authorized to specify this digital property</faultstring>
|
7
|
+
<detail>
|
8
|
+
<ns1:exceptionName xmlns:ns1="http://xml.apache.org/axis/">com.akamai.aws.util.AWSFault</ns1:exceptionName>
|
9
|
+
<ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">example.akamai.com</ns2:hostname>
|
10
|
+
</detail>
|
11
|
+
</soapenv:Fault>
|
12
|
+
</soapenv:Body>
|
13
|
+
</soapenv:Envelope>
|
@@ -0,0 +1,8 @@
|
|
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
|
+
<uploadResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
5
|
+
<fileId xsi:type="xsd:int">1234567</fileId>
|
6
|
+
</uploadResponse>
|
7
|
+
</soapenv:Body>
|
8
|
+
</soapenv:Envelope>
|
@@ -0,0 +1,15 @@
|
|
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>
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module AkamaiApi
|
4
|
+
describe Ccu do
|
5
|
+
include SavonTester
|
6
|
+
|
7
|
+
before do
|
8
|
+
savon.expects('wsdl:purgeRequest').returns(:success)
|
9
|
+
stub_savon_model Ccu
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#purge response' do
|
13
|
+
it 'is a CcuResponse object' do
|
14
|
+
Ccu.remove_cpcode('12345').should be_a CcuResponse
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'returns code 100' do
|
18
|
+
Ccu.remove_cpcode('12345').code.should == 100
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'returns a success message' do
|
22
|
+
Ccu.remove_cpcode('12345').message.should == 'Success.'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns a unique session id' do
|
26
|
+
Ccu.remove_cpcode('12345').session_id.should == '97870328-018c-11e2-aabc-489beabc489b'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns the estimated time in seconds' do
|
30
|
+
Ccu.remove_cpcode('12345').estimated_time.should == 420
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#purge raises an error when' do
|
35
|
+
it 'action is not allowed' do
|
36
|
+
%w(invalidate remove).each do |action|
|
37
|
+
expect {
|
38
|
+
Ccu.purge action, :cpcode, '1234'
|
39
|
+
}.to_not raise_error
|
40
|
+
end
|
41
|
+
expect { Ccu.purge :sss, :cpcode, '12345' }.to raise_error
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'type is not allowed' do
|
45
|
+
%w(cpcode arl).each do |type|
|
46
|
+
expect {
|
47
|
+
Ccu.purge :remove, type, '12345'
|
48
|
+
}.to_not raise_error
|
49
|
+
end
|
50
|
+
expect { Ccu.purge :remove, :foo, '12345' }.to raise_error
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'domain is specified and not allowed' do
|
54
|
+
%w(production staging).each do |domain|
|
55
|
+
expect { Ccu.purge :remove, :arl, 'foo', :domain => domain }.to_not raise_error
|
56
|
+
end
|
57
|
+
expect { Ccu.purge :remove, :arl, 'foo', :domain => :foo }.to raise_error
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#purge request arguments' do
|
62
|
+
it 'should include user and password' do
|
63
|
+
soap_body = SoapBody.any_instance
|
64
|
+
soap_body.stub :string => ''
|
65
|
+
soap_body.should_receive(:string).with :name, AkamaiApi.config[:auth].first
|
66
|
+
soap_body.should_receive(:string).with :pwd, AkamaiApi.config[:auth].last
|
67
|
+
Ccu.purge :remove, :arl, 'foo'
|
68
|
+
end
|
69
|
+
|
70
|
+
describe 'options' do
|
71
|
+
before { SoapBody.any_instance.stub :array => '' }
|
72
|
+
|
73
|
+
it 'include action and type' do
|
74
|
+
SoapBody.any_instance.should_receive(:array).with(:opt, kind_of(Array)) do |name, array|
|
75
|
+
array.should include 'type=arl'
|
76
|
+
array.should include 'action=remove'
|
77
|
+
end
|
78
|
+
Ccu.purge :remove, :arl, 'foo'
|
79
|
+
end
|
80
|
+
|
81
|
+
describe 'domain' do
|
82
|
+
it 'is not included by default' do
|
83
|
+
SoapBody.any_instance.should_receive(:array).with(:opt, kind_of(Array)) do |name, array|
|
84
|
+
array.detect { |s| s =~ /^domain/ }.should be_nil
|
85
|
+
end
|
86
|
+
Ccu.purge :remove, :arl, 'foo'
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'is included if specified' do
|
90
|
+
SoapBody.any_instance.should_receive(:array).with(:opt, kind_of(Array)) do |name, array|
|
91
|
+
array.should include 'domain=production'
|
92
|
+
end
|
93
|
+
Ccu.purge :remove, :arl, 'foo', :domain => 'production'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'email' do
|
98
|
+
it 'is not included by default' do
|
99
|
+
SoapBody.any_instance.should_receive(:array).with(:opt, kind_of(Array)) do |name, array|
|
100
|
+
array.detect { |s| s =~ /^email/ }.should be_nil
|
101
|
+
end
|
102
|
+
Ccu.purge :remove, :arl, 'foo'
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'is included if specified' do
|
106
|
+
SoapBody.any_instance.should_receive(:array).with(:opt, kind_of(Array)) do |name, array|
|
107
|
+
array.should include 'email-notification=foo@foo.com,pip@pip.com'
|
108
|
+
end
|
109
|
+
Ccu.purge :remove, :arl, 'foo', :email => ['foo@foo.com', 'pip@pip.com']
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module AkamaiApi
|
4
|
+
describe CpCode do
|
5
|
+
include SavonTester
|
6
|
+
|
7
|
+
describe '::all' do
|
8
|
+
before do
|
9
|
+
savon.expects('getCPCodes').returns(:sample)
|
10
|
+
stub_savon_model CpCode
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should return a collection of models' do
|
14
|
+
CpCode.all.each { |o| o.should be_a CpCode }
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should correctly fill each object' do
|
18
|
+
model = CpCode.all.first
|
19
|
+
model.code.should == '12345'
|
20
|
+
model.description.should == 'Foo Site'
|
21
|
+
model.service.should == 'Site_Accel::Site_Accel'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|