class Cumulus::CloudFront::CacheBehaviorDiff

Public: Represents a single difference between local configuration and AWS configuration of zones.

Attributes

allowed_methods[RW]
cached_methods[RW]
cookies[RW]
headers[RW]
signers[RW]

Public Class Methods

allowed_methods(added_allowed_methods, removed_allowed_methods, local) click to toggle source

Public: Static method that produces a diff representing changes in CacheBehavior allowed methods

added_allowed_methods - the allowed methods that were added removed_allowed_methods - the allowed methods that were removed local - the local configuration for the zone

Returns the diff

# File lib/cloudfront/models/CacheBehaviorDiff.rb, line 86
def self.allowed_methods(added_allowed_methods, removed_allowed_methods, local)
  diff = CacheBehaviorDiff.new(METHODS_ALLOWED, nil, local)
  diff.allowed_methods = Common::ListChange.new(added_allowed_methods, removed_allowed_methods)
  diff
end
cached_methods(added_cached_methods, removed_cached_methods, local) click to toggle source

Public: Static method that produces a diff representing changes in CacheBehavior cached methods

added_cached_methods - the cached methods that were added removed_cached_methods - the cached methods that were removed local - the local configuration for the zone

Returns the diff

# File lib/cloudfront/models/CacheBehaviorDiff.rb, line 99
def self.cached_methods(added_cached_methods, removed_cached_methods, local)
  diff = CacheBehaviorDiff.new(METHODS_CACHED, nil, local)
  diff.cached_methods = Common::ListChange.new(added_cached_methods, removed_cached_methods)
  diff
end
cookies_whitelist(added_cookies, removed_cookies, local) click to toggle source

Public: Static method that produces a diff representing changes in CacheBehavior cookies whitelist

added_cookies - the cookies that were added removed_cookies - the cookies that were removed local - the local configuration for the zone

Returns the diff

# File lib/cloudfront/models/CacheBehaviorDiff.rb, line 47
def self.cookies_whitelist(added_cookies, removed_cookies, local)
  diff = CacheBehaviorDiff.new(COOKIES_WHITELIST, nil, local)
  diff.cookies = Common::ListChange.new(added_cookies, removed_cookies)
  diff
end
headers(added_headers, removed_headers, local) click to toggle source

Public: Static method that produces a diff representing changes in CacheBehavior headers

added_headers - the headers that were added removed_headers - the headers that were removed local - the local configuration for the zone

Returns the diff

# File lib/cloudfront/models/CacheBehaviorDiff.rb, line 60
def self.headers(added_headers, removed_headers, local)
  diff = CacheBehaviorDiff.new(HEADERS, nil, local)
  diff.headers = Common::ListChange.new(added_headers, removed_headers)
  diff
end
signers(added_signers, removed_signers, local) click to toggle source

Public: Static method that produces a diff representing changes in CacheBehavior trusted signers

added_signers - the trusted signers that were added removed_signers - the trusted signers that were removed local - the local configuration for the zone

Returns the diff

# File lib/cloudfront/models/CacheBehaviorDiff.rb, line 73
def self.signers(added_signers, removed_signers, local)
  diff = CacheBehaviorDiff.new(SIGNERS, nil, local)
  diff.signers = Common::ListChange.new(added_signers, removed_signers)
  diff
end

Public Instance Methods

asset_type() click to toggle source
# File lib/cloudfront/models/CacheBehaviorDiff.rb, line 200
def asset_type
  "Cache Behavior"
end
aws_name() click to toggle source
# File lib/cloudfront/models/CacheBehaviorDiff.rb, line 204
def aws_name
  "#{@aws.target_origin_id}/#{@aws.path_pattern}"
end
diff_string() click to toggle source
# File lib/cloudfront/models/CacheBehaviorDiff.rb, line 105
def diff_string
  case @type
  when PATH
    [
      "path:",
      Colors.aws_changes("\tAWS - #{@aws.path_pattern}"),
      Colors.local_changes("\tLocal - #{@local.path_pattern}"),
    ].join("\n")
  when TARGET
    [
      "target origin id:",
      Colors.aws_changes("\tAWS - #{@aws.target_origin_id}"),
      Colors.local_changes("\tLocal - #{@local.target_origin_id}"),
    ].join("\n")
  when QUERY
    [
      "forward query strings:",
      Colors.aws_changes("\tAWS - #{@aws.forwarded_values.query_string}"),
      Colors.local_changes("\tLocal - #{@local.forward_query_strings}"),
    ].join("\n")
  when COOKIES
    [
      "forwarded cookies:",
      Colors.aws_changes("\tAWS - #{@aws.forwarded_values.cookies.forward}"),
      Colors.local_changes("\tLocal - #{@local.forwarded_cookies}"),
    ].join("\n")
  when COOKIES_WHITELIST
    [
      "whitelisted forwarded cookies:",
      cookies.removed.map{ |removed| Colors.removed("\t#{removed}")},
      cookies.added.map{ |added| Colors.added("\t#{added}")},
    ].flatten.join("\n")
  when HEADERS
    [
      "forwarded headers:",
      headers.removed.map{ |removed| Colors.removed("\t#{removed}")},
      headers.added.map{ |added| Colors.added("\t#{added}")},
    ].flatten.join("\n")
  when SIGNERS
    [
      "trusted signers:",
      signers.removed.map{ |removed| Colors.removed("\t#{removed}")},
      signers.added.map{ |added| Colors.added("\t#{added}")},
    ].flatten.join("\n")
  when VIEWER_PROTOCOL
    [
      "viewer protocol policy:",
      Colors.aws_changes("\tAWS - #{@aws.viewer_protocol_policy}"),
      Colors.local_changes("\tLocal - #{@local.viewer_protocol_policy}"),
    ].join("\n")
  when MINTTL
    [
      "min ttl:",
      Colors.aws_changes("\tAWS - #{@aws.min_ttl}"),
      Colors.local_changes("\tLocal - #{@local.min_ttl}"),
    ].join("\n")
  when MAXTTL
    [
      "max ttl:",
      Colors.aws_changes("\tAWS - #{@aws.max_ttl}"),
      Colors.local_changes("\tLocal - #{@local.max_ttl}"),
    ].join("\n")
  when DEFTTL
    [
      "default ttl:",
      Colors.aws_changes("\tAWS - #{@aws.default_ttl}"),
      Colors.local_changes("\tLocal - #{@local.default_ttl}"),
    ].join("\n")
  when STREAMING
    [
      "smooth streaming:",
      Colors.aws_changes("\tAWS - #{@aws.smooth_streaming}"),
      Colors.local_changes("\tLocal - #{@local.smooth_streaming}"),
    ].join("\n")
  when METHODS_ALLOWED
    [
      "allowed methods:",
      allowed_methods.removed.map{ |removed| Colors.removed("\t#{removed}")},
      allowed_methods.added.map{ |added| Colors.added("\t#{added}")},
    ].flatten.join("\n")
  when METHODS_CACHED
    [
      "cached methods:",
      cached_methods.removed.map{ |removed| Colors.removed("\t#{removed}")},
      cached_methods.added.map{ |added| Colors.added("\t#{added}")},
    ].flatten.join("\n")
  when COMPRESS
    [
      "compress:",
      Colors.aws_changes("\tAWS - #{@aws.compress}"),
      Colors.local_changes("\tLocal - #{@local.compress}"),
    ].join("\n")
  end
end