class AWS::Core::Response
response.http_response #=> #<AWS::Core::Http::Response>
response.http_request #=> #<AWS::Core::Http::Request>
response.request_options #=> { :instance_ids => [‘i-12345678’] }
response.request_type #=> :describe_instances
Given the example and response object from above:
* the HTTP response object (useful for debugging)
* the HTTP request object (useful for debugging)
* the hash of options passed to the client request
* the name of the client request method called
available with the response, including:
In addition to the response data, there is additional information
== Response Metadata<br><br>instance #=> ‘running’
instance = response.data.first.first
instance = response.first.first
# find the instance in the response data (2 ways to get the data)
response = ec2.client.describe_instances(:instance_ids => [‘i-12345678’])
ec2 = AWS::EC2.new
# make a request to describe one instance
calling {#data} (you can also use the {#[]} method as a shortcut)
returned by the service. You can get at this data by
Each response has a hash of data that represents the data
== Response Data
access to response data and request/response metadata.
Each service request returns a response object. Responses provide
= Response
def [] key
-
(Hash, nil)
-
Parameters:
-
key
(Symbol, String
) --
def [] key data[key] end
def cache_key
- Private: -
Returns:
-
(String)
-
def cache_key [ http_request.access_key_id, http_request.host, request_type, serialized_options ].join(":") end
def initialize http_request = nil, http_response = nil, &block
-
http_response
(Http::Response
) -- -
http_request
(Http::Request
) --
def initialize http_request = nil, http_response = nil, &block @http_request = http_request @http_response = http_response @request_builder = block @data = {} @retry_count = 0 @duration = 0 rebuild_request if @request_builder && !http_request end
def inspect
- Private: -
Returns:
-
(String)
-
def inspect data.inspect end
def method_missing *args, &block
- See: #data -
See: #[] -
Other tags:
- Note: - The prefered method to get as response data is to use {#[]}.
def method_missing *args, &block Core::Data.new(data).send(*args, &block) end
def rebuild_request
- Private: -
def rebuild_request @http_request = @request_builder.call end
def serialize_options_array array
def serialize_options_array array "[" + array.map{|v| serialize_options_value(v) }.join(" ") + "]" end
def serialize_options_hash(hash)
def serialize_options_hash(hash) "(" + hash.keys.sort_by(&:to_s).map do |key| "#{key}=#{serialize_options_value(hash[key])}" end.join(" ") + ")" end
def serialize_options_value(value)
def serialize_options_value(value) case value when Hash then serialize_options_hash(value) when Array then serialize_options_array(value) else value.inspect end end
def serialized_options
def serialized_options serialize_options_hash(request_options) end
def successful?
-
(Boolean)
- Returns true if there is no response error.
def successful? error.nil? end
def throttled?
-
(Boolean)
- Returns true if the http request was throttled
def throttled? if !successful? and http_response.body error = XML::Parser.new.parse(http_response.body) error = error[:error] if error[:error] error[:code] == "Throttling" else false end end
def timeout?
-
(Boolean)
- Returns true if the http request timed out.
def timeout? http_response.timeout? end