1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[aws|dns] Add Record#modify method.

Deletes the current record and creates a new record
in a single request.
This commit is contained in:
Aaron Suggs 2011-11-29 13:59:48 -05:00
parent 3541452f18
commit ef6f8cd06c

View file

@ -23,14 +23,7 @@ module Fog
end
def destroy
requires :name, :ttl, :type, :value, :zone
options = {
:action => 'DELETE',
:name => name,
:resource_records => [*value],
:ttl => ttl,
:type => type
}
options = attributes_to_options('DELETE')
connection.change_resource_record_sets(zone.id, [options])
true
end
@ -40,25 +33,44 @@ module Fog
end
def save
requires :name, :ttl, :type, :value, :zone
options = {
:action => 'CREATE',
:name => name,
:resource_records => [*value],
:ttl => ttl,
:type => type
}
options = attributes_to_options('CREATE')
data = connection.change_resource_record_sets(zone.id, [options]).body
merge_attributes(data)
true
end
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
private
def zone=(new_zone)
@zone = new_zone
end
def attributes_to_options(action)
requires :name, :ttl, :type, :value, :zone
{
:action => action,
:name => name,
:resource_records => [*value],
:ttl => ttl,
:type => type
}
end
end
end