2010-12-23 15:36:08 -08:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
2011-06-15 17:25:01 -07:00
|
|
|
module DNS
|
|
|
|
class Slicehost
|
2010-12-23 15:36:08 -08:00
|
|
|
|
|
|
|
class Record < Fog::Model
|
2011-05-27 10:30:20 -07:00
|
|
|
extend Fog::Deprecation
|
|
|
|
deprecate :ip, :value
|
|
|
|
deprecate :ip=, :value=
|
2010-12-23 15:36:08 -08:00
|
|
|
|
|
|
|
identity :id
|
|
|
|
|
|
|
|
attribute :active
|
2011-11-08 16:14:30 +09:00
|
|
|
attribute :value, :aliases => ['ip', 'data']
|
2010-12-23 15:36:08 -08:00
|
|
|
attribute :name
|
2010-12-23 16:47:47 -08:00
|
|
|
attribute :description, :aliases => 'aux'
|
2010-12-23 15:36:08 -08:00
|
|
|
attribute :ttl
|
2010-12-23 16:47:47 -08:00
|
|
|
attribute :type, :aliases => 'record_type'
|
2010-12-23 15:36:08 -08:00
|
|
|
attribute :zone_id
|
|
|
|
|
|
|
|
def initialize(attributes={})
|
|
|
|
self.active ||= true
|
|
|
|
self.ttl ||= 3600
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def active=(new_active)
|
|
|
|
attributes[:active] = case new_active
|
|
|
|
when false, 'N'
|
|
|
|
false
|
|
|
|
when true, 'Y'
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :identity
|
|
|
|
connection.delete_record(identity)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def zone
|
|
|
|
@zone
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
2011-11-08 18:12:25 +09:00
|
|
|
|
2011-05-27 10:30:20 -07:00
|
|
|
requires :name, :type, :value, :zone
|
2010-12-23 15:36:08 -08:00
|
|
|
options = {}
|
|
|
|
options[:active] = active ? 'Y' : 'N'
|
2011-01-03 15:39:38 -08:00
|
|
|
options[:aux] = description if description
|
2010-12-23 15:36:08 -08:00
|
|
|
options[:ttl] = ttl if ttl
|
2011-11-08 18:12:25 +09:00
|
|
|
if identity
|
|
|
|
data = connection.update_record(identity, type, zone.id, name, value, options)
|
|
|
|
else
|
|
|
|
data = connection.create_record(type, zone.id, name, value, options)
|
|
|
|
end
|
2010-12-23 15:36:08 -08:00
|
|
|
merge_attributes(data.body)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def zone=(new_zone)
|
|
|
|
@zone = new_zone
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|