class Route53::AWSResponse
Constants
- MESSAGES
Attributes
raw_data[R]
Public Class Methods
new(resp,conn)
click to toggle source
# File lib/route53/aws_response.rb, line 17 def initialize(resp,conn) @raw_data = unescape(resp) if error? $stderr.puts "ERROR: Amazon returned an error for the request." $stderr.puts "ERROR: RAW_XML: "+@raw_data $stderr.puts "ERROR: "+error_message $stderr.puts "" $stderr.puts "What now? "+helpful_message #exit 1 end @conn = conn @created = Time.now puts "Raw: #{@raw_data}" if @conn.verbose end
Public Instance Methods
complete?()
click to toggle source
# File lib/route53/aws_response.rb, line 49 def complete? return true if error? if @change_url.nil? change = Nokogiri::XML(@raw_data).search("ChangeInfo") if change.size > 0 @change_url = change.first.search("Id").first.inner_text else return false end end if @complete.nil? || @complete == false status = Nokogiri::XML(@conn.request(@conn.base_url+@change_url).raw_data).search("Status") @complete = status.size > 0 && status.first.inner_text == "INSYNC" ? true : false if !@complete && @created - Time.now > 60 $stderr.puts "WARNING: Amazon Route53 Change timed out on Sync. This may not be an issue as it may just be Amazon being assy. Then again your request may not have completed.'" @complete = true end end return @complete end
error?()
click to toggle source
# File lib/route53/aws_response.rb, line 32 def error? return Nokogiri::XML(@raw_data).search("ErrorResponse").size > 0 end
error_message()
click to toggle source
# File lib/route53/aws_response.rb, line 36 def error_message xml = Nokogiri::XML(@raw_data) msg_code = xml.search("Code") msg_text = xml.search("Message") return (msg_code.size > 0 ? msg_code.first.inner_text : "") + (msg_text.size > 0 ? ': ' + msg_text.first.inner_text : "") end
helpful_message()
click to toggle source
# File lib/route53/aws_response.rb, line 43 def helpful_message xml = Nokogiri::XML(@raw_data) msg_code = xml.search("Code").first.inner_text MESSAGES[msg_code] || MESSAGES["Other"] end
pending?()
click to toggle source
# File lib/route53/aws_response.rb, line 70 def pending? #Return opposite of complete via XOR return complete? ^ true end
to_s()
click to toggle source
# File lib/route53/aws_response.rb, line 75 def to_s return @raw_data end
unescape(string)
click to toggle source
# File lib/route53/aws_response.rb, line 79 def unescape(string) string.gsub(/\\0(\d{2})/) { $1.oct.chr } end