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:
* {#http_response} - the HTTP response received
* {#http_request} - The HTTP request made
* {#request_options} - the hash of options passed to the client method
* {#request_type} - the name of the client request method
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
a shortcut for accessing this hash.
method or the {#[]} method. Response data is a hash and {#[]} is
You can access the response data for a client request using the {#data}
## Response Data
about the HTTP request made and the HTTP response received.
In addition to the response data, these responses provide metadata
object.
operation defined on the client. These methods all return a {Response}
Each Service has a Client class. There is one method per service
# Response
def [] key
-
(Hash, nil)
-
Parameters:
-
key
(Symbol, String
) --
def [] key data[key] end
def build_request
def build_request @http_request = @request_builder.call end
def cache_key
- Api: - 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 build_request if @request_builder && !http_request end
def inspect
- Api: - 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 network_error?
-
(Boolean)
- Returns `true` if the http request failed due to
def network_error? http_response.network_error? end
def rebuild_request
- Api: - private
def rebuild_request @http_request.body_stream.rewind if @http_request.body_stream build_request end
def safe_to_retry?
-
(Boolean)
- Returns `false` if it is not safe to retry a
def safe_to_retry? @http_request.body_stream.nil? or @http_request.body_stream.respond_to?(:rewind) 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