1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[aws|cdn] Implements AWS CDN get_invalidation request

This request was missing from the implementation. It is needed if
you actually need to look-up the invalidated paths.

Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
This commit is contained in:
Brice Figureau 2012-09-20 20:25:27 +02:00
parent 9ea51f3d01
commit b381ba90e2
4 changed files with 82 additions and 0 deletions

View file

@ -17,6 +17,7 @@ module Fog
request 'get_distribution'
request 'get_distribution_list'
request 'get_invalidation_list'
request 'get_invalidation'
request 'get_streaming_distribution'
request 'get_streaming_distribution_list'
request 'post_distribution'

View file

@ -0,0 +1,30 @@
module Fog
module Parsers
module CDN
module AWS
class GetInvalidation < Fog::Parsers::Base
def reset
@response = { 'InvalidationBatch' => [] }
end
def start_element(name, attrs = [])
super
end
def end_element(name)
case name
when 'Path'
@response['InvalidationBatch'] << @value
when 'Id', 'Status', 'CreateTime'
@response[name] = @value
end
end
end
end
end
end
end

View file

@ -0,0 +1,34 @@
module Fog
module CDN
class AWS
class Real
require 'fog/aws/parsers/cdn/get_invalidation'
# ==== Parameters
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'Id'<~String> - Invalidation id
# * 'Status'<~String>
# * 'CreateTime'<~String>
# * 'InvalidationBatch'<~Array>:
# * 'Path'<~String>
# ==== See Also
# http://docs.amazonwebservices.com/AmazonCloudFront/2010-11-01/APIReference/GetInvalidation.html
def get_invalidation(distribution_id, invalidation_id)
request({
:expects => 200,
:idempotent => true,
:method => 'GET',
:parser => Fog::Parsers::CDN::AWS::GetInvalidation.new,
:path => "/distribution/#{distribution_id}/invalidation/#{invalidation_id}"
})
end
end
end
end
end

View file

@ -101,6 +101,23 @@ Shindo.tests('Fog::CDN[:aws] | CDN requests', ['aws', 'cdn']) do
result
}
test("get invalidation information") {
pending if Fog.mocking?
result = false
response = @cf_connection.get_invalidation(@dist_id, @invalidation_id)
if response.status == 200
paths = response.body['InvalidationBatch'].sort
status = response.body['Status']
if status.length > 0 and paths == [ '/test.html', '/path/to/file.html' ].sort
result = true
end
end
result
}
test("disable distribution #{@dist_id}") {
pending if Fog.mocking?