class AWS::CloudFront::Distribution

Public Class Methods

new(svc, data) click to toggle source
# File lib/aws/with-stacco-patches.rb, line 144
def initialize(svc, data)
  @svc = svc
  @data = data
end

Public Instance Methods

aliases() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 176
def aliases
  @data[:distribution_config][:aliases][:items]
end
certificate() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 237
def certificate
  @data[:distribution_config][:viewer_certificate][:iam_certificate_id]
end
certificate=(cert_id) click to toggle source
# File lib/aws/with-stacco-patches.rb, line 241
def certificate=(cert_id)
  @data[:distribution_config][:viewer_certificate] = {
    iam_certificate_id: cert_id,
    ssl_support_method: "sni-only"
  }
end
change_in_status() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 193
def change_in_status
  new_status = self.status rescue :nonexistent
  old_status = @prev_status
  @prev_status = new_status

  return nil unless old_status and old_status != new_status
  {from: old_status, to: new_status}
end
config() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 184
def config
  self.make_exportable(@data[:distribution_config])
end
eql?(o) click to toggle source
# File lib/aws/with-stacco-patches.rb, line 153
def eql?(o)
  o.kind_of?(self.class) and o.id == self.id
end
hash() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 157
def hash
  self.class.hash + self.id.hash
end
id() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 180
def id
  @data[:id]
end
invalidate(obj_keys) click to toggle source
# File lib/aws/with-stacco-patches.rb, line 165
def invalidate(obj_keys)
  return false if obj_keys.empty?
  @svc.client.create_invalidation(distribution_id: self.id, invalidation_batch: {
    caller_reference: rand(36 ** 32).to_s(36).rjust(32, '0'),
    paths: {
      quantity: obj_keys.length,
      items: obj_keys.map{ |k| k.to_s }
    }
  })
end
make_exportable(o) click to toggle source
# File lib/aws/with-stacco-patches.rb, line 202
def make_exportable(o)
  case o
  when nil
    ""
  when Hash
    h = {}
    o.each{ |k, v| h[k] = make_exportable(v) }
    h
  when Array
    o.map{ |e| make_exportable(e) }
  else
    o
  end
end
price_class() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 229
def price_class
  @data[:distribution_config][:price_class].split('_').last.downcase.intern
end
price_class=(new_class) click to toggle source
# File lib/aws/with-stacco-patches.rb, line 233
def price_class=(new_class)
  @data[:distribution_config][:price_class] = "PriceClass_#{new_class.to_s.capitalize}"
end
refresh!() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 161
def refresh!
  @data = @svc.client.get_distribution(id: @data[:id])
end
status() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 188
def status
  self.refresh!
  @data[:status]
end
tags() click to toggle source
# File lib/aws/with-stacco-patches.rb, line 149
def tags
  {}
end
update() { || ... } click to toggle source
# File lib/aws/with-stacco-patches.rb, line 217
def update
  begin
    yield

    @svc.client.update_distribution(
      id: self.id,
      distribution_config: self.config,
      if_match: @data[:etag]
    )
  end
end