1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/zerigo/models/dns/record.rb

69 lines
1.7 KiB
Ruby
Raw Normal View History

require 'fog/core/model'
module Fog
module DNS
class Zerigo
class Record < Fog::Model
extend Fog::Deprecation
deprecate :ip, :value
deprecate :ip=, :value=
identity :id
attribute :created_at, :aliases => 'created-at'
attribute :value, :aliases => 'data'
attribute :domain, :aliases => 'fqdn'
attribute :name, :aliases => 'hostname'
2010-12-23 19:47:47 -05:00
attribute :description, :aliases => 'notes'
attribute :priority
attribute :ttl
attribute :type, :aliases => 'host-type'
attribute :updated_at, :aliases => 'updated-at'
attribute :zone_id, :aliases => 'zone-id'
2010-12-23 18:36:08 -05:00
def initialize(attributes={})
self.ttl ||= 3600
super
end
def destroy
requires :identity
connection.delete_host(identity)
true
end
def zone
@zone
end
def save
requires :zone, :type, :value
options = {}
options[:hostname] = name if name
options[:notes] = description if description
options[:priority] = priority if priority
options[:ttl] = ttl if ttl
2010-12-23 17:21:05 -05:00
data = unless identity
connection.create_host(@zone.id, type, value, options)
2010-12-23 17:21:05 -05:00
else
options[:host_type] = type
options[:data] = value
2010-12-23 17:21:05 -05:00
connection.update_host(identity, options)
end
merge_attributes(data.body)
true
end
private
def zone=(new_zone)
@zone = new_zone
end
end
end
end
end