Skip to content
Browse files

Dynect returns false data when a node exists, but is not published

  • Loading branch information...
1 parent 9e331d5 commit 7c718974c055238e3f4e4c38c137636c4c557fa2 @adamhjk adamhjk committed Jun 16, 2010
Showing with 10 additions and 2 deletions.
  1. +1 −0 lib/dynect_rest.rb
  2. +9 −2 lib/dynect_rest/resource.rb
View
1 lib/dynect_rest.rb
@@ -173,6 +173,7 @@ def api_request(&block)
response = block.call
response.body
rescue RestClient::Exception => e
+ puts "I have #{e.inspect} with #{e.http_code}"
if e.http_code == 307
get(e.response)
end
View
11 lib/dynect_rest/resource.rb
@@ -69,7 +69,14 @@ def get(fqdn, record_id=nil)
record =~ /^#{resource_path(:full)}\/#{fqdn}\/(\d+)$/
raw_rr_list << self.get(fqdn, $1)
end
- raw_rr_list.length == 1 ? raw_rr_list[0] : raw_rr_list
+ case raw_rr_list.length
+ when 0
+ raise DynectRest::Exceptions::RequestFailed, "Cannot find #{record_type} record for #{fqdn}"
+ when 1
+ raw_rr_list[0]
+ else
+ raw_rr_list
+ end
end
end
@@ -85,7 +92,7 @@ def find(fqdn, query_hash)
def save(replace=false)
if record_id
- @dynect.put("#{resource_path}/#{@fqdn}/#{@record_id}", self)
+ @dynect.put("#{resource_path}/#{@fqdn}/#{record_id}", self)
else
if replace == true || replace == :replace
@dynect.put("#{resource_path}/#{@fqdn}", self)

0 comments on commit 7c71897

Please sign in to comment.
Something went wrong with that request. Please try again.