| Class | AWS::Core::Response |
| In: |
lib/aws/core/response.rb
|
| Parent: | Object |
# Response
Each Service has a Client class. There is one method per service operation defined on the client. These methods all return a {Response} object.
In addition to the response data, these responses provide metadata about the HTTP request made and the HTTP response received.
You can access the response data for a client request using the {data} method or the {#[]} method. Response data is a hash and {#[]} is a shortcut for accessing this hash.
# make a request to describe one instance
ec2 = AWS::EC2.new
response = ec2.client.describe_instances(:instance_ids => ['i-12345678'])
# find the instance in the response data (2 ways to get the data)
instance = response[:reservation_set].first[:instance_set].first
instance = response.data[:reservation_set].first[:instance_set].first
instance[:status] #=> 'running'
## Response Metadata
In addition to the response data, there is additional information available with the response, including:
Given the example and response object from above:
response.request_type #=> :describe_instances
response.request_options #=> { :instance_ids => ['i-12345678'] }
response.http_request #=> #<AWS::Core::Http::Request>
response.http_response #=> #<AWS::Core::Http::Response>
| cached | -> | cached? |
| api_version | [RW] | @return [String] The API version of the request/client. |
| cached | [RW] |
@return [Boolean] true if the response was generated from a
another cached response. |
| config | [RW] | @api private |
| data | [RW] | @return [Hash] Returns the response data as a hash. |
| duration | [RW] |
@return [Float] The total number of seconds taken to make the
request and return the response. |
| error | [RW] |
@return [AWS::Error,nil] Returns nil unless the request failed.
Normally this will be nil unless you are using the Asynchronous interface. |
| http_request | [RW] | @return [Core::Http::Request] |
| http_response | [RW] | @return [Core::Http::Response] |
| request_options | [RW] |
@return [Hash] Returns the hash of options passed to the client
request method that generated this response. |
| request_type | [RW] |
@return [Symbol] The name of the client request method that
returned this response. |
| retry_count | [RW] |
@return [Integer] Returns the number of times the request
was retried. |
@param [Http::Request] http_request @param [Http::Response] http_response
Provides access to the response data. This is a short-cut for calling `response.data[key]`.
@param [Symbol,String] key @return [Hash,nil]
Rebuilds the HTTP request using the block passed to the initializer. This is primarily used by the client when a request must be retried (throttling, server errors, socket errors, etc). @api private
@return [Boolean] Returns `false` if it is not safe to retry a
request. This happens when the http request body is an IO object that can not be rewound and re-streamed.