2010-12-23 19:47:47 -05:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
2011-06-15 20:25:01 -04:00
|
|
|
module DNS
|
|
|
|
class Linode
|
2010-12-23 19:47:47 -05:00
|
|
|
|
|
|
|
class Record < Fog::Model
|
2011-05-27 13:30:20 -04:00
|
|
|
extend Fog::Deprecation
|
|
|
|
deprecate :ip, :value
|
|
|
|
deprecate :ip=, :value=
|
2010-12-23 19:47:47 -05:00
|
|
|
|
|
|
|
identity :id, :aliases => ['ResourceID', 'RESOURCEID']
|
|
|
|
|
2011-05-27 13:30:20 -04:00
|
|
|
attribute :value, :aliases => 'TARGET'
|
2010-12-23 19:47:47 -05:00
|
|
|
attribute :name, :aliases => 'NAME'
|
|
|
|
attribute :priority, :aliases => 'PRIORITY'
|
|
|
|
attribute :ttl, :aliases => 'TTL_SEC'
|
|
|
|
attribute :type, :aliases => 'TYPE'
|
|
|
|
attribute :zone_id, :aliases => 'DOMAINID'
|
|
|
|
|
|
|
|
# "PROTOCOL":"",
|
|
|
|
# "WEIGHT":0,
|
|
|
|
# "PORT":0,
|
|
|
|
|
|
|
|
def initialize(attributes={})
|
|
|
|
self.ttl ||= 3600
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2011-01-03 18:39:38 -05:00
|
|
|
requires :identity, :zone
|
|
|
|
connection.domain_resource_delete(zone.id, identity)
|
2010-12-23 19:47:47 -05:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def zone
|
|
|
|
@zone
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
|
|
|
requires :type, :zone
|
|
|
|
options = {}
|
|
|
|
# * options<~Hash>
|
|
|
|
# * weight<~Integer>: default: 5
|
|
|
|
# * port<~Integer>: default: 80
|
|
|
|
# * protocol<~String>: The protocol to append to an SRV record. Ignored on other record
|
|
|
|
# types. default: udp
|
|
|
|
options[:name] = name if name
|
|
|
|
options[:priority] = priority if priority
|
2011-05-27 13:30:20 -04:00
|
|
|
options[:target] = value if value
|
2010-12-23 19:47:47 -05:00
|
|
|
options[:ttl_sec] = ttl if ttl
|
2011-01-03 18:39:38 -05:00
|
|
|
response = unless identity
|
|
|
|
connection.domain_resource_create(zone.identity, type, options)
|
2010-12-23 19:47:47 -05:00
|
|
|
else
|
|
|
|
options[:type] = type if type
|
2011-01-03 18:39:38 -05:00
|
|
|
connection.domain_resource_update(zone.identity, identity, options)
|
2010-12-23 19:47:47 -05:00
|
|
|
end
|
2011-01-03 18:39:38 -05:00
|
|
|
merge_attributes(response.body['DATA'])
|
2010-12-23 19:47:47 -05:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def zone=(new_zone)
|
|
|
|
@zone = new_zone
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|