2010-12-22 23:36:53 -05:00
|
|
|
require 'fog/core/collection'
|
2011-08-24 15:40:47 -04:00
|
|
|
require 'fog/zerigo/models/dns/record'
|
2010-12-22 23:36:53 -05:00
|
|
|
|
|
|
|
module Fog
|
2011-06-15 20:25:01 -04:00
|
|
|
module DNS
|
|
|
|
class Zerigo
|
2010-12-22 23:36:53 -05:00
|
|
|
|
|
|
|
class Records < Fog::Collection
|
|
|
|
|
|
|
|
attribute :zone
|
|
|
|
|
2011-06-15 20:25:01 -04:00
|
|
|
model Fog::DNS::Zerigo::Record
|
2010-12-22 23:36:53 -05:00
|
|
|
|
|
|
|
def all
|
|
|
|
requires :zone
|
|
|
|
parent = zone.collection.get(zone.identity)
|
|
|
|
if parent
|
|
|
|
merge_attributes(parent.records.attributes)
|
|
|
|
load(parent.records.map {|record| record.attributes})
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(record_id)
|
|
|
|
data = connection.get_host(record_id).body
|
|
|
|
new(data)
|
2011-01-03 18:39:38 -05:00
|
|
|
rescue Fog::Service::NotFound
|
2010-12-22 23:36:53 -05:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def new(attributes = {})
|
|
|
|
requires :zone
|
|
|
|
super({ :zone => zone }.merge!(attributes))
|
|
|
|
end
|
|
|
|
|
2011-10-08 22:39:40 -04:00
|
|
|
def find(fqdn)
|
|
|
|
hosts = connection.find_hosts(fqdn, zone.id).body['hosts']
|
|
|
|
hosts.collect { |host| new(host) }
|
|
|
|
end
|
|
|
|
|
2010-12-22 23:36:53 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|