Class: Bisques::AwsResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/bisques/aws_response.rb

Overview

Created by an AwsRequest to represent the returned details. The original request is stored in #request. The raw content is available in #content. AWS returns XML, and a Nokogiri::XML instance is available in #doc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, http_response) ⇒ AwsResponse

:nodoc:



15
16
17
18
19
# File 'lib/bisques/aws_response.rb', line 15

def initialize(request, http_response) # :nodoc:
  @request = request
  @http_response = http_response
  @content = @http_response.body
end

Instance Attribute Details

#contentString (readonly)

Returns The raw response string from AWS.

Returns:

  • (String)

    The raw response string from AWS



11
12
13
# File 'lib/bisques/aws_response.rb', line 11

def content
  @content
end

#http_response#body, ... (readonly)

Returns The HTTP response. This can be used to get any headers or status codes.

Returns:

  • (#body, #status, #header)

    The HTTP response. This can be used to get any headers or status codes.



13
14
15
# File 'lib/bisques/aws_response.rb', line 13

def http_response
  @http_response
end

#requestAwsRequest (readonly)

Returns The original AwsRequest that created this response.

Returns:

  • (AwsRequest)

    The original AwsRequest that created this response.



9
10
11
# File 'lib/bisques/aws_response.rb', line 9

def request
  @request
end

Instance Method Details

#docNokogiri::XML

A Nokogiri::XML document parsed from the #content.

Returns:

  • (Nokogiri::XML)

    XML document



24
25
26
# File 'lib/bisques/aws_response.rb', line 24

def doc
  @doc ||= Nokogiri::XML(content).tap{|x|x.remove_namespaces!}
end

#request_idString

Returns The request ID from AWS.

Returns:

  • (String)

    The request ID from AWS.



34
35
36
# File 'lib/bisques/aws_response.rb', line 34

def request_id
  @http_response.header['x-amzn-RequestId']
end

#success?Boolean

Returns true if the request was successful.

Returns:

  • (Boolean)

    Returns true if the request was successful.



29
30
31
# File 'lib/bisques/aws_response.rb', line 29

def success?
  @http_response.ok?
end