Sha256: 58b640ea9ad8874e9b4ee4ce98e1bdd5528010abdf229f82d92c7775127bdf61

Contents?: true

Size: 1.43 KB

Versions: 40

Compression:

Stored size: 1.43 KB

Contents

module Fog
  module CDN
    class AWS
      module DistributionHelper
        def destroy
          requires :identity, :etag, :caller_reference
          raise "Distribution must be disabled to be deleted" unless disabled?
          delete_distribution(identity, etag)
          true
        end

        def enabled?
          requires :identity
          !!enabled and ready?
        end

        def disabled?
          requires :identity
          not enabled? and ready?
        end

        def custom_origin?
          requires :identity
          not custom_origin.nil?
        end

        def ready?
          requires :identity
          status == 'Deployed'
        end

        def enable
          requires :identity
          reload if etag.nil? or caller_reference.nil?
          unless enabled?
            self.enabled = true
            response = put_distribution_config(identity, etag, attributes_to_options)
            etag = response.headers['ETag']
            merge_attributes(response.body)
          end
          true
        end

        def disable
          requires :identity
          reload if etag.nil? or caller_reference.nil?
          if enabled?
            self.enabled = false
            response = put_distribution_config(identity, etag, attributes_to_options)
            etag = response.headers['ETag']
            merge_attributes(response.body)
          end
          true
        end
      end
    end
  end
end

Version data entries

40 entries across 38 versions & 3 rubygems

Version Path
fog-aws-3.2.0 lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-3.1.0 lib/fog/aws/models/cdn/distribution_helper.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-aws-2.0.1/lib/fog/aws/models/cdn/distribution_helper.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-aws-2.0.1/lib/fog/aws/models/cdn/distribution_helper.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-aws-2.0.1/lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-3.0.0 lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-2.0.1 lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-2.0.0 lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-1.4.1 lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-1.4.0 lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-1.3.0 lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-1.2.1 lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-1.2.0 lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-1.1.0 lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-1.0.0 lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-0.13.0 lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-0.12.0 lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-0.11.0 lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-0.10.0 lib/fog/aws/models/cdn/distribution_helper.rb
fog-aws-0.9.4 lib/fog/aws/models/cdn/distribution_helper.rb