diff --git a/lib/fog/dynect/dns.rb b/lib/fog/dynect/dns.rb index 34f0155c7..24f6c4321 100644 --- a/lib/fog/dynect/dns.rb +++ b/lib/fog/dynect/dns.rb @@ -18,6 +18,7 @@ module Fog request_path 'fog/dynect/requests/dns' request :delete_record request :delete_zone + request :get_node_list request :get_all_records request :get_record request :get_zone diff --git a/lib/fog/dynect/requests/dns/get_node_list.rb b/lib/fog/dynect/requests/dns/get_node_list.rb new file mode 100644 index 000000000..3418c2153 --- /dev/null +++ b/lib/fog/dynect/requests/dns/get_node_list.rb @@ -0,0 +1,56 @@ +module Fog + module DNS + class Dynect + class Real + + # Get one or more node lists + # + # ==== Parameters + # * zone<~String> - zone to lookup node lists for + # * options<~Hash> + # * fqdn<~String> - fully qualified domain name of node to lookup + + def get_node_list(zone, options = {}) + requested_fqdn = options['fqdn'] || options[:fqdn] + request( + :expects => 200, + :idempotent => true, + :method => :get, + :path => ['AllRecord', zone, requested_fqdn].compact.join('/') + ) + end + end + + class Mock + def get_node_list(zone, options = {}) + raise Fog::DNS::Dynect::NotFound unless zone = self.data[:zones][zone] + + response = Excon::Response.new + response.status = 200 + + data = [zone[:zone]] + + if fqdn = options[:fqdn] + data = data | zone[:records].collect { |type, records| records.select { |record| record[:fqdn] == fqdn } }.flatten.compact + else + data = data | zone[:records].collect { |type, records| records.collect { |record| record[:fqdn] } }.flatten + end + + response.body = { + "status" => "success", + "data" => data, + "job_id" => Fog::Dynect::Mock.job_id, + "msgs" => [{ + "INFO" => "get_tree: Here is your zone tree", + "SOURCE" => "BLL", + "ERR_CD" => nil, + "LVL" => "INFO" + }] + } + + response + end + end + end + end +end diff --git a/tests/dynect/requests/dns/dns_tests.rb b/tests/dynect/requests/dns/dns_tests.rb index a65deb868..bac3d60c5 100644 --- a/tests/dynect/requests/dns/dns_tests.rb +++ b/tests/dynect/requests/dns/dns_tests.rb @@ -116,6 +116,14 @@ Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do @dns.get_node_list(@domain).body end + get_all_records_format = shared_format.merge({ + 'data' => [String] + }) + + tests("get_all_records('#{@domain}')").formats(get_all_records_format) do + @dns.get_all_records(@domain).body + end + get_records_format = shared_format.merge({ 'data' => [String] })