2014-01-21 14:39:48 -05:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module DNS
|
|
|
|
class Rage4
|
|
|
|
|
|
|
|
class Record < Fog::Model
|
2014-01-23 16:27:04 -05:00
|
|
|
|
2014-01-21 14:39:48 -05:00
|
|
|
|
|
|
|
identity :id
|
|
|
|
|
2014-01-23 18:47:24 -05:00
|
|
|
attribute :name
|
2014-01-21 14:39:48 -05:00
|
|
|
attribute :value, :aliases => "content"
|
|
|
|
attribute :ttl
|
|
|
|
attribute :zone_id, :aliases => "domain_id"
|
|
|
|
attribute :type, :aliases => "record_type"
|
2014-01-24 10:25:51 -05:00
|
|
|
attribute :priority, :aliases => "priority"
|
|
|
|
attribute :domain_id
|
|
|
|
attribute :geo_region_id
|
|
|
|
attribute :failover_enabled
|
|
|
|
attribute :failover_content
|
|
|
|
attribute :geo_lat
|
|
|
|
attribute :geo_long
|
|
|
|
attribute :geo_lock
|
|
|
|
attribute :is_active
|
|
|
|
|
2014-01-21 14:39:48 -05:00
|
|
|
|
|
|
|
def initialize(attributes={})
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
2014-01-23 18:47:24 -05:00
|
|
|
def domain
|
|
|
|
name
|
|
|
|
end
|
|
|
|
|
2014-01-21 14:39:48 -05:00
|
|
|
def destroy
|
2014-02-04 20:10:48 -05:00
|
|
|
service.delete_record(id)
|
2014-01-21 14:39:48 -05:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def zone
|
|
|
|
@zone
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
|
|
|
requires :name, :type, :value
|
|
|
|
options = {}
|
2014-01-24 10:25:51 -05:00
|
|
|
options[:priority] = priority if priority
|
2014-01-21 14:39:48 -05:00
|
|
|
options[:ttl] = ttl if ttl
|
2014-01-24 10:25:51 -05:00
|
|
|
options[:geozone] = geo_region_id if geo_region_id
|
|
|
|
options[:geolock] = geo_lock if geo_lock
|
|
|
|
options[:geolat] = geo_lat if geo_lat
|
|
|
|
options[:geolong] = geo_long if geo_long
|
2014-01-21 14:39:48 -05:00
|
|
|
|
|
|
|
# decide whether its a new record or update of an existing
|
|
|
|
if id.nil?
|
2014-01-23 16:27:04 -05:00
|
|
|
data = service.create_record(zone.id, name, value, type, options)
|
2014-01-21 14:39:48 -05:00
|
|
|
else
|
2014-01-23 16:27:04 -05:00
|
|
|
data = service.update_record(id, name, value, type, options)
|
2014-01-21 14:39:48 -05:00
|
|
|
end
|
|
|
|
|
2014-01-23 16:27:04 -05:00
|
|
|
merge_attributes(options)
|
2014-02-04 18:05:01 -05:00
|
|
|
merge_attributes(:name => name, :value => value, :type => type)
|
2014-01-21 14:39:48 -05:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def zone=(new_zone)
|
|
|
|
@zone = new_zone
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|