Sha256: 9568f7af20adaab7a4f70aa67bc1345b3a2cecced1c299d277851ee2c8bdc017

Contents?: true

Size: 1.88 KB

Versions: 58

Compression:

Stored size: 1.88 KB

Contents

module Fog
  module CDN
    class AWS
      class Real

        require 'fog/aws/parsers/cdn/get_invalidation'

        # Get invalidation.
        # 
        # @param distribution_id [String] Distribution id.
        # @param invalidation_id [String] Invalidation id.
        #   
        # @return [Excon::Response]
        #   * body [Hash]:
        #     * Id [String] - Invalidation id.
        #     * Status [String]
        #     * CreateTime [String]
        #     * InvalidationBatch [Array]:
        #       * Path [String]
        # 
        # @see 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

      class Mock

        def get_invalidation(distribution_id, invalidation_id)
          distribution = self.data[:distributions][distribution_id]
          unless distribution
            Fog::CDN::AWS::Mock.error(:no_such_distribution)
          end

          invalidation = self.data[:invalidations][distribution_id][invalidation_id]
          unless invalidation
            Fog::CDN::AWS::Mock.error(:no_such_invalidation)
          end

          if invalidation['Status'] == 'InProgress' && (Time.now - Time.parse(invalidation['CreateTime']) >= Fog::Mock.delay * 2)
            invalidation['Status'] = 'Completed'
            distribution['InProgressInvalidationBatches'] -= 1
          end

          response = Excon::Response.new
          response.status = 200
          response.body = invalidation
          response
        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/get_invalidation.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-1.20.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-1.19.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.18.0.20131209090811 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-maestrodev-1.18.0.20131206115947 lib/fog/aws/requests/cdn/get_invalidation.rb