From d954a16354872b4c87a1a1ad760c5ea366ebe8cd Mon Sep 17 00:00:00 2001 From: Andreas Gerauer Date: Wed, 13 Mar 2013 09:35:12 +0100 Subject: [PATCH] Removed Zerigo::Models::DNS::Records#find method, moved functionality to all(options) Removed Rackspace::Models::DNS::Zones#find, moved functionality to all(options) --- lib/fog/rackspace/models/dns/zones.rb | 14 +++++--------- lib/fog/zerigo/models/dns/records.rb | 27 +++++++++++++++------------ 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/lib/fog/rackspace/models/dns/zones.rb b/lib/fog/rackspace/models/dns/zones.rb index b9524cf5b..9de234f25 100644 --- a/lib/fog/rackspace/models/dns/zones.rb +++ b/lib/fog/rackspace/models/dns/zones.rb @@ -8,21 +8,17 @@ module Fog model Fog::DNS::Rackspace::Zone + # List all domains. Return by default a maximum of 100 items + # @param [Hash] options Options to pass to the underlying API call + # @option options [String] :name search for domains containing the given substring + # @option options [Integer] :limit number of records to return + # @option options [Integer] :offset starting offset of records to return def all(options={}) clear data = service.list_domains(options).body['domains'] load(data) end - # Returns all domains containing the given substring. Still limited - # by the 100-domain pagination limit. Returns an empty array if - # no matches. - def find(substring) - clear - data = service.list_domains(:name => substring).body['domains'] - load(data) - end - alias :each_zone_this_page :each def each if !block_given? diff --git a/lib/fog/zerigo/models/dns/records.rb b/lib/fog/zerigo/models/dns/records.rb index 5682a7532..eca25255d 100644 --- a/lib/fog/zerigo/models/dns/records.rb +++ b/lib/fog/zerigo/models/dns/records.rb @@ -10,15 +10,23 @@ module Fog attribute :zone model Fog::DNS::Zerigo::Record - - def all + + # List all domains + # @param [Hash] options Options to pass to the underlying API call + # @option options [String] :fqdn search for the given fqdn + def all(options = {}) requires :zone - parent = zone.collection.get(zone.identity) - if parent - merge_attributes(parent.records.attributes) - load(parent.records.map {|record| record.attributes}) + if options[:fqdn] + hosts = service.find_hosts(options[:fqdn], zone.id).body['hosts'] + load(hosts) else - nil + parent = zone.collection.get(zone.identity) + if parent + merge_attributes(parent.records.attributes) + load(parent.records.map {|record| record.attributes}) + else + nil + end end end @@ -34,11 +42,6 @@ module Fog super({ :zone => zone }.merge!(attributes)) end - def find(fqdn) - hosts = service.find_hosts(fqdn, zone.id).body['hosts'] - hosts.collect { |host| new(host) } - end - end end