2011-06-16 17:51:13 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/dns/models/dynect/record'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Dynect
|
|
|
|
class DNS
|
|
|
|
|
|
|
|
class Records < Fog::Collection
|
|
|
|
|
|
|
|
attribute :zone
|
|
|
|
|
|
|
|
model Fog::Dynect::DNS::Record
|
|
|
|
|
2011-06-19 04:22:42 -04:00
|
|
|
def all(filter=nil)
|
2011-06-19 04:09:58 -04:00
|
|
|
selected_nodes = nodes
|
|
|
|
selected_nodes = nodes.select do |node|
|
2011-06-19 04:22:42 -04:00
|
|
|
node =~ /#{Regexp.escape(filter)}$/
|
|
|
|
end if filter
|
2011-06-19 04:09:58 -04:00
|
|
|
|
|
|
|
data = selected_nodes.inject([]) do |m, node|
|
|
|
|
m += connection.list_any_records(zone.id, node).map(&:body)
|
|
|
|
m
|
|
|
|
end
|
|
|
|
|
|
|
|
load(data)
|
2011-06-16 17:51:13 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(record_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def new(attributes = {})
|
2011-06-16 18:04:01 -04:00
|
|
|
requires :zone
|
|
|
|
super({ :zone => zone }.merge!(attributes))
|
2011-06-16 17:51:13 -04:00
|
|
|
end
|
|
|
|
|
2011-06-19 04:09:58 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
def nodes
|
|
|
|
requires :zone
|
|
|
|
Array(connection.node_list(zone.id).body)
|
|
|
|
end
|
|
|
|
|
2011-06-16 17:51:13 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|