2011-01-03 17:45:50 -05:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class DNS
|
|
|
|
|
|
|
|
class Record < Fog::Model
|
2011-05-27 13:30:20 -04:00
|
|
|
extend Fog::Deprecation
|
|
|
|
deprecate :ip, :value
|
|
|
|
deprecate :ip=, :value=
|
2011-01-03 17:45:50 -05:00
|
|
|
|
|
|
|
identity :id, :aliases => ['Id']
|
|
|
|
|
2011-05-27 13:30:20 -04:00
|
|
|
attribute :value, :aliases => ['ResourceRecords']
|
2011-01-03 17:45:50 -05:00
|
|
|
attribute :name, :aliases => ['Name']
|
|
|
|
attribute :ttl, :aliases => ['TTL']
|
|
|
|
attribute :type, :aliases => ['Type']
|
|
|
|
attribute :status, :aliases => ['Status']
|
|
|
|
attribute :created_at, :aliases => ['SubmittedAt']
|
|
|
|
|
|
|
|
def initialize(attributes={})
|
2011-04-04 19:57:08 -04:00
|
|
|
self.ttl ||= 3600
|
2011-01-03 17:45:50 -05:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2011-05-27 13:30:20 -04:00
|
|
|
requires :name, :ttl, :type, :value, :zone
|
2011-01-03 17:45:50 -05:00
|
|
|
options = {
|
|
|
|
:action => 'DELETE',
|
|
|
|
:name => name,
|
2011-05-27 13:30:20 -04:00
|
|
|
:resource_records => [*value],
|
2011-01-03 17:45:50 -05:00
|
|
|
:ttl => ttl,
|
|
|
|
:type => type
|
|
|
|
}
|
|
|
|
connection.change_resource_record_sets(zone.id, [options])
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def zone
|
|
|
|
@zone
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
2011-05-27 13:30:20 -04:00
|
|
|
requires :name, :ttl, :type, :value, :zone
|
2011-01-03 17:45:50 -05:00
|
|
|
options = {
|
|
|
|
:action => 'CREATE',
|
|
|
|
:name => name,
|
2011-05-27 13:30:20 -04:00
|
|
|
:resource_records => [*value],
|
2011-01-03 17:45:50 -05:00
|
|
|
:ttl => ttl,
|
|
|
|
:type => type
|
|
|
|
}
|
|
|
|
data = connection.change_resource_record_sets(zone.id, [options]).body
|
|
|
|
merge_attributes(data)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def zone=(new_zone)
|
|
|
|
@zone = new_zone
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|