Sha256: d949b461aa3b7b71194962dd04919e40caab7df47685d4a7ee4f595df2ba86ba

Contents?: true

Size: 1.47 KB

Versions: 48

Compression:

Stored size: 1.47 KB

Contents

module Awspec::Type
  class CloudfrontDistribution < ResourceBase
    def resource_via_client
      @resource_via_client ||= find_cloudfront_distribution(@display_name)
    end

    def id
      @id ||= resource_via_client.id if resource_via_client
    end

    STATUSES = %w(
      InProgress Deployed
    )

    STATUSES.each do |status|
      define_method status.underscore + '?' do
        resource_via_client.status == status
      end
    end

    def has_origin?(origin_id,
                    domain_name: nil,
                    origin_path: nil,
                    origin_access_identity: nil)
      return false unless [origin_id, domain_name].any?
      resource_via_client.origins.items.find do |origin|
        next false if !origin_id.nil? && origin.id != origin_id
        next false if !domain_name.nil? && origin.domain_name != domain_name
        next false if !origin_path.nil? && origin.origin_path != origin_path
        next false if !origin_access_identity.nil? && \
                      origin.s3_origin_config.origin_access_identity != origin_access_identity
        true
      end
    end

    def has_origin_domain_name?(domain_name)
      has_origin?(nil, domain_name: domain_name)
    end

    def has_origin_domain_name_and_path?(domain_name_and_path)
      domain_name = domain_name_and_path.gsub(%r(/.*\z), '')
      origin_path = domain_name_and_path.gsub(%r(\A[^/]*), '')
      has_origin?(nil, domain_name: domain_name, origin_path: origin_path)
    end
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
awspec-1.3.1 lib/awspec/type/cloudfront_distribution.rb
awspec-1.3.0 lib/awspec/type/cloudfront_distribution.rb
awspec-1.2.0 lib/awspec/type/cloudfront_distribution.rb
awspec-1.1.0 lib/awspec/type/cloudfront_distribution.rb
awspec-1.0.0 lib/awspec/type/cloudfront_distribution.rb
awspec-1.0.0.rc lib/awspec/type/cloudfront_distribution.rb
awspec-0.88.2 lib/awspec/type/cloudfront_distribution.rb
awspec-0.88.1 lib/awspec/type/cloudfront_distribution.rb
awspec-0.88.0 lib/awspec/type/cloudfront_distribution.rb
awspec-0.87.1 lib/awspec/type/cloudfront_distribution.rb
awspec-0.87.0 lib/awspec/type/cloudfront_distribution.rb
awspec-0.86.0 lib/awspec/type/cloudfront_distribution.rb
cmonson_2ndwatch_awspec-0.85.4 lib/awspec/type/cloudfront_distribution.rb
awspec-0.85.3 lib/awspec/type/cloudfront_distribution.rb
cmonson_2ndwatch_awspec-0.85.3 lib/awspec/type/cloudfront_distribution.rb
awspec-0.85.2 lib/awspec/type/cloudfront_distribution.rb
awspec-0.85.1 lib/awspec/type/cloudfront_distribution.rb
awspec-0.85.0 lib/awspec/type/cloudfront_distribution.rb
awspec-0.84.1 lib/awspec/type/cloudfront_distribution.rb
awspec-0.84.0 lib/awspec/type/cloudfront_distribution.rb