Sha256: 94fd68c0317b04904edb4eb8ad72ef248ba44143d31cabd3c992bb2c5aa3fcb8

Contents?: true

Size: 1.86 KB

Versions: 36

Compression:

Stored size: 1.86 KB

Contents

module Fog
  module AWS
    class CDN
      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::AWS::CDN::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::AWS::CDN::Mock.error(:no_such_distribution)
          end

          invalidation = self.data[:invalidations][distribution_id][invalidation_id]
          unless invalidation
            Fog::AWS::CDN::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

36 entries across 36 versions & 1 rubygems

Version Path
fog-aws-3.30.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.29.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.28.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.27.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.26.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.25.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.24.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.23.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.22.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.21.1 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.21.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.20.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.19.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.18.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.17.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.16.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.15.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.14.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.13.0 lib/fog/aws/requests/cdn/get_invalidation.rb
fog-aws-3.12.0 lib/fog/aws/requests/cdn/get_invalidation.rb