Sha256: fc7b365ebbc90d5e54e650712caa7bee04d426e3706650a8db916e0d57ca3867

Contents?: true

Size: 1.7 KB

Versions: 58

Compression:

Stored size: 1.7 KB

Contents

module Fog
  module CDN
    class AWS
      class Real

        # Delete a distribution from CloudFront.
        #
        # @param distribution_id [String] Id of distribution to delete.
        # @param etag [String] etag of that distribution from earlier get or put
        #
        # @see http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/DeleteDistribution.html
        
        def delete_distribution(distribution_id, etag)
          request({
            :expects    => 204,
            :headers    => { 'If-Match' => etag },
            :idempotent => true,
            :method     => 'DELETE',
            :path       => "/distribution/#{distribution_id}"
          })
        end

      end

      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

    end
  end
end

Version data entries

58 entries across 58 versions & 6 rubygems

Version Path
fog-maestrodev-1.20.0.20140305101839 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-1.20.0 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-1.19.0 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.18.0.20131209090811 lib/fog/aws/requests/cdn/delete_distribution.rb
fog-maestrodev-1.18.0.20131206115947 lib/fog/aws/requests/cdn/delete_distribution.rb