diff --git a/Gemfile.lock b/Gemfile.lock index cce6a4283..27f9530fa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -21,7 +21,7 @@ GEM formatador (0.0.16) json (1.5.1) mime-types (1.16) - net-ssh (2.1.0) + net-ssh (2.1.3) nokogiri (1.4.4) rake (0.8.7) rspec (1.3.1) diff --git a/lib/fog/dns/dnsimple.rb b/lib/fog/dns/dnsimple.rb index 7cd576de2..db8bec535 100644 --- a/lib/fog/dns/dnsimple.rb +++ b/lib/fog/dns/dnsimple.rb @@ -21,6 +21,7 @@ module Fog request :list_records request :update_record request :delete_record + request :get_record class Mock diff --git a/lib/fog/dns/models/dnsimple/records.rb b/lib/fog/dns/models/dnsimple/records.rb index c5306dd2f..8d199024e 100644 --- a/lib/fog/dns/models/dnsimple/records.rb +++ b/lib/fog/dns/models/dnsimple/records.rb @@ -17,12 +17,10 @@ module Fog end def get(record_id) - all.each do |record| - if record["record"]["id"] == record_id - return new(record) - end - end - + requires :zone + data = connection.get_record(zone.id, record_id).body["record"] + new(data) + rescue Excon::Errors::NotFound nil end diff --git a/lib/fog/dns/requests/dnsimple/get_record.rb b/lib/fog/dns/requests/dnsimple/get_record.rb new file mode 100644 index 000000000..06eed804e --- /dev/null +++ b/lib/fog/dns/requests/dnsimple/get_record.rb @@ -0,0 +1,34 @@ +module Fog + module DNSimple + class DNS + class Real + + # Gets record from given domain. + # + # ==== Parameters + # * domain<~String> + # * record_id<~String> + # ==== Returns + # * response<~Excon::Response>: + # * record<~Hash> + # * name<~String> + # * ttl<~Integer> + # * created_at<~String> + # * special_type<~String> + # * updated_at<~String> + # * domain_id<~Integer> + # * id<~Integer> + # * content<~String> + # * record_type<~String> + # * prio<~Integer> + def get_record(domain, record_id) + + request( :expects => 200, + :method => "GET", + :path => "/domains/#{domain}/records/#{record_id}" ) + end + + end + end + end +end