2010-11-01 20:44:14 -04:00
|
|
|
module Fog
|
2011-06-15 20:32:15 -04:00
|
|
|
module CDN
|
|
|
|
class AWS
|
2010-11-01 20:44:14 -04:00
|
|
|
class Real
|
|
|
|
|
2013-03-10 18:14:57 -04:00
|
|
|
# Delete a distribution from CloudFront.
|
2010-11-01 20:44:14 -04:00
|
|
|
#
|
2013-03-10 18:14:57 -04:00
|
|
|
# @param distribution_id [String] Id of distribution to delete.
|
|
|
|
# @param etag [String] etag of that distribution from earlier get or put
|
2010-11-01 20:44:14 -04:00
|
|
|
#
|
2013-03-10 18:14:57 -04:00
|
|
|
# @see http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/DeleteDistribution.html
|
|
|
|
|
2010-11-01 20:44:14 -04:00
|
|
|
def delete_distribution(distribution_id, etag)
|
|
|
|
request({
|
|
|
|
:expects => 204,
|
2010-11-02 14:17:09 -04:00
|
|
|
:headers => { 'If-Match' => etag },
|
2010-11-01 20:44:14 -04:00
|
|
|
:idempotent => true,
|
|
|
|
:method => 'DELETE',
|
|
|
|
:path => "/distribution/#{distribution_id}"
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2012-09-27 18:00:16 -04:00
|
|
|
|
|
|
|
class Mock
|
|
|
|
|
|
|
|
def delete_distribution(distribution_id, etag)
|
|
|
|
distribution = self.data[:distributions][distribution_id]
|
|
|
|
|
|
|
|
if distribution
|
|
|
|
if distribution['ETag'] != etag
|
|
|
|
Fog::CDN::AWS::Mock.error(:invalid_if_match_version)
|
|
|
|
end
|
|
|
|
unless distribution['DistributionConfig']['CallerReference']
|
|
|
|
Fog::CDN::AWS::Mock.error(:illegal_update)
|
|
|
|
end
|
|
|
|
if distribution['DistributionConfig']['Enabled']
|
|
|
|
Fog::CDN::AWS::Mock.error(:distribution_not_disabled)
|
|
|
|
end
|
|
|
|
|
|
|
|
self.data[:distributions].delete(distribution_id)
|
|
|
|
self.data[:invalidations].delete(distribution_id)
|
|
|
|
|
|
|
|
response = Excon::Response.new
|
|
|
|
response.status = 204
|
|
|
|
response.body = "x-amz-request-id: #{Fog::AWS::Mock.request_id}"
|
|
|
|
response
|
|
|
|
else
|
|
|
|
Fog::CDN::AWS::Mock.error(:no_such_distribution)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2010-11-01 20:44:14 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|