class Fog::DNS::AWS::Record

Public Class Methods

new(attributes={}) click to toggle source
Calls superclass method Fog::Model.new
# File lib/fog/aws/models/dns/record.rb, line 25
def initialize(attributes={})
  self.ttl ||= 3600
  super
end

Public Instance Methods

destroy() click to toggle source
# File lib/fog/aws/models/dns/record.rb, line 30
def destroy
  options = attributes_to_options('DELETE')
  connection.change_resource_record_sets(zone.id, [options])
  true
end
modify(new_attributes) click to toggle source
# File lib/fog/aws/models/dns/record.rb, line 47
def modify(new_attributes)
  options = []

  # Delete the current attributes
  options << attributes_to_options('DELETE')

  # Create the new attributes
  merge_attributes(new_attributes)
  options << attributes_to_options('CREATE')

  data = connection.change_resource_record_sets(zone.id, options).body
  merge_attributes(data)
  true
end
ready?() click to toggle source

Returns true if record is insync. May only be called for newly created or modified records that have a change_id and status set.

# File lib/fog/aws/models/dns/record.rb, line 64
def ready?
  requires :change_id, :status
  status == 'INSYNC'
end
reload() click to toggle source
Calls superclass method Fog::Model#reload
# File lib/fog/aws/models/dns/record.rb, line 69
def reload
  # If we have a change_id (newly created or modified), then reload performs a get_change to update status.
  if change_id
    data = connection.get_change(change_id).body
    merge_attributes(data)
    self
  else
    super
  end
end
save() click to toggle source
# File lib/fog/aws/models/dns/record.rb, line 40
def save
  options = attributes_to_options('CREATE')
  data = connection.change_resource_record_sets(zone.id, [options]).body
  merge_attributes(data)
  true
end
zone() click to toggle source
# File lib/fog/aws/models/dns/record.rb, line 36
def zone
  @zone
end

Private Instance Methods

attributes_to_options(action) click to toggle source
# File lib/fog/aws/models/dns/record.rb, line 86
def attributes_to_options(action)
  requires :name, :ttl, :type, :zone
  requires_one :value, :alias_target
  {
      :action           => action,
      :name             => name,
      :resource_records => [*value],
      :alias_target     => symbolize_keys(alias_target),
      :ttl              => ttl,
      :type             => type,
      :weight           => weight,
      :set_identifier   => set_identifier,
      :region           => region
  }
end
zone=(new_zone) click to toggle source
# File lib/fog/aws/models/dns/record.rb, line 82
def zone=(new_zone)
  @zone = new_zone
end