Class: Cumulus::CloudFront::DistributionConfig
- Inherits:
-
Object
- Object
- Cumulus::CloudFront::DistributionConfig
- Defined in:
- lib/cloudfront/models/DistributionConfig.rb
Overview
Public: An object representing configuration for a distribution
Instance Attribute Summary collapse
-
#aliases ⇒ Object
readonly
Returns the value of attribute aliases.
-
#cache_behaviors ⇒ Object
readonly
Returns the value of attribute cache_behaviors.
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#default_cache_behavior ⇒ Object
readonly
Returns the value of attribute default_cache_behavior.
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#origins ⇒ Object
readonly
Returns the value of attribute origins.
Instance Method Summary collapse
-
#diff(aws) ⇒ Object
Public: Produce an array of differences between this local configuration and the configuration in AWS.
-
#initialize(name, json = nil) ⇒ DistributionConfig
constructor
Public: Constructor.
- #populate!(id, aws) ⇒ Object
-
#pretty_json ⇒ Object
Public: Get the config as a prettified JSON string.
Constructor Details
#initialize(name, json = nil) ⇒ DistributionConfig
Public: Constructor
json - a hash containing the JSON configuration for the distribution
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cloudfront/models/DistributionConfig.rb', line 24 def initialize(name, json = nil) @name = name if !json.nil? @id = json["id"] @aliases = json["aliases"] || [] @origins = json["origins"].map { |o| OriginConfig.new(o) } @default_cache_behavior = CacheBehaviorConfig.new(json["default-cache-behavior"], true) @cache_behaviors = (json["cache-behaviors"] || []).map { |cb| CacheBehaviorConfig.new(cb) } @comment = json["comment"] @enabled = json["enabled"] end end |
Instance Attribute Details
#aliases ⇒ Object (readonly)
Returns the value of attribute aliases.
14 15 16 |
# File 'lib/cloudfront/models/DistributionConfig.rb', line 14 def aliases @aliases end |
#cache_behaviors ⇒ Object (readonly)
Returns the value of attribute cache_behaviors.
17 18 19 |
# File 'lib/cloudfront/models/DistributionConfig.rb', line 17 def cache_behaviors @cache_behaviors end |
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
18 19 20 |
# File 'lib/cloudfront/models/DistributionConfig.rb', line 18 def comment @comment end |
#default_cache_behavior ⇒ Object (readonly)
Returns the value of attribute default_cache_behavior.
16 17 18 |
# File 'lib/cloudfront/models/DistributionConfig.rb', line 16 def default_cache_behavior @default_cache_behavior end |
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled.
19 20 21 |
# File 'lib/cloudfront/models/DistributionConfig.rb', line 19 def enabled @enabled end |
#id ⇒ Object
Returns the value of attribute id.
12 13 14 |
# File 'lib/cloudfront/models/DistributionConfig.rb', line 12 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/cloudfront/models/DistributionConfig.rb', line 13 def name @name end |
#origins ⇒ Object (readonly)
Returns the value of attribute origins.
15 16 17 |
# File 'lib/cloudfront/models/DistributionConfig.rb', line 15 def origins @origins end |
Instance Method Details
#diff(aws) ⇒ Object
Public: Produce an array of differences between this local configuration and the configuration in AWS
aws - the AWS resource
Returns an array of the DistributionDiffs that were found
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/cloudfront/models/DistributionConfig.rb', line 78 def diff(aws) diffs = [] added_aliases = (@aliases - aws.aliases.items) removed_aliases = aws.aliases.items - @aliases if !added_aliases.empty? or !removed_aliases.empty? diffs << DistributionDiff.aliases(added_aliases, removed_aliases, self) end origin_diffs = diff_origins(aws.origins.items) if !origin_diffs.empty? diffs << DistributionDiff.origins(origin_diffs, self) end default_cache_diffs = @default_cache_behavior.diff(aws.default_cache_behavior) if !default_cache_diffs.empty? diffs << DistributionDiff.default_cache(default_cache_diffs, self) end diffs << diff_caches(aws) if @comment != aws.comment diffs << DistributionDiff.new(DistributionChange::COMMENT, aws, self) end if @enabled != aws.enabled diffs << DistributionDiff.new(DistributionChange::ENABLED, aws, self) end diffs.flatten end |
#populate!(id, aws) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cloudfront/models/DistributionConfig.rb', line 37 def populate!(id, aws) @id = id @name = id @aliases = aws.aliases.items @origins = aws.origins.items.map do |origin| config = OriginConfig.new() config.populate!(origin) config end @default_cache_behavior = CacheBehaviorConfig.new() @default_cache_behavior.populate!(aws.default_cache_behavior, true) @cache_behaviors = aws.cache_behaviors.items.map do |cache_behavior| config = CacheBehaviorConfig.new() config.populate!(cache_behavior) config end @comment = aws.comment @enabled = aws.enabled end |
#pretty_json ⇒ Object
Public: Get the config as a prettified JSON string.
Returns the JSON string
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cloudfront/models/DistributionConfig.rb', line 60 def pretty_json JSON.pretty_generate({ "id" => @id, "aliases" => @aliases, "origins" => @origins.map(&:to_local), "default-cache-behavior" => @default_cache_behavior.to_local, "cache-behaviors" => @cache_behaviors.map(&:to_local), "comment" => @comment, "enabled" => @enabled, }) end |