Sha256: 25df5ed74172abea195b41bf3ba97cccac6a5a0eae91d5933a20a907f91d59e0

Contents?: true

Size: 1.46 KB

Versions: 26

Compression:

Stored size: 1.46 KB

Contents

module Awspec::Type
  class CloudfrontDistribution < Base
    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

26 entries across 26 versions & 1 rubygems

Version Path
awspec-0.69.1 lib/awspec/type/cloudfront_distribution.rb
awspec-0.69.0 lib/awspec/type/cloudfront_distribution.rb
awspec-0.68.0 lib/awspec/type/cloudfront_distribution.rb
awspec-0.67.1 lib/awspec/type/cloudfront_distribution.rb
awspec-0.67.0 lib/awspec/type/cloudfront_distribution.rb
awspec-0.66.2 lib/awspec/type/cloudfront_distribution.rb
awspec-0.66.1 lib/awspec/type/cloudfront_distribution.rb
awspec-0.66.0 lib/awspec/type/cloudfront_distribution.rb
awspec-0.65.2 lib/awspec/type/cloudfront_distribution.rb
awspec-0.65.1 lib/awspec/type/cloudfront_distribution.rb
awspec-0.65.0 lib/awspec/type/cloudfront_distribution.rb
awspec-0.64.0 lib/awspec/type/cloudfront_distribution.rb
awspec-0.63.1 lib/awspec/type/cloudfront_distribution.rb
awspec-0.63.0 lib/awspec/type/cloudfront_distribution.rb
awspec-0.62.1 lib/awspec/type/cloudfront_distribution.rb
awspec-0.62.0 lib/awspec/type/cloudfront_distribution.rb
awspec-0.61.1 lib/awspec/type/cloudfront_distribution.rb
awspec-0.61.0 lib/awspec/type/cloudfront_distribution.rb
awspec-0.60.1 lib/awspec/type/cloudfront_distribution.rb
awspec-0.60.0 lib/awspec/type/cloudfront_distribution.rb