Class: Google::Cloud::Env::ComputeMetadata::Response
- Inherits:
-
Object
- Object
- Google::Cloud::Env::ComputeMetadata::Response
- Defined in:
- lib/google/cloud/env/compute_metadata.rb
Overview
Basic HTTP response object, returned by #lookup_response.
This object duck-types the status
, body
, and headers
fields of
Faraday::Response
. It also includes the CLOCK_MONOTONIC time when
the data was retrieved.
Instance Attribute Summary collapse
-
#body ⇒ String
readonly
The HTTP response body.
-
#headers ⇒ Hash{String=>String}
readonly
The HTTP response headers.
-
#retrieval_monotonic_time ⇒ Numeric
readonly
The CLOCK_MONOTONIC time at which this response was retrieved.
-
#status ⇒ Integer
readonly
The HTTP status code.
Instance Method Summary collapse
-
#google_flavor? ⇒ boolean
Returns true if the metadata-flavor is correct for Google Cloud.
-
#initialize(status, body, headers) ⇒ Response
constructor
Create a response object.
Constructor Details
#initialize(status, body, headers) ⇒ Response
Create a response object.
105 106 107 108 109 110 |
# File 'lib/google/cloud/env/compute_metadata.rb', line 105 def initialize status, body, headers @status = status @body = body @headers = headers @retrieval_monotonic_time = Process.clock_gettime Process::CLOCK_MONOTONIC end |
Instance Attribute Details
#body ⇒ String (readonly)
The HTTP response body
122 123 124 |
# File 'lib/google/cloud/env/compute_metadata.rb', line 122 def body @body end |
#headers ⇒ Hash{String=>String} (readonly)
The HTTP response headers
128 129 130 |
# File 'lib/google/cloud/env/compute_metadata.rb', line 128 def headers @headers end |
#retrieval_monotonic_time ⇒ Numeric (readonly)
The CLOCK_MONOTONIC time at which this response was retrieved.
133 134 135 |
# File 'lib/google/cloud/env/compute_metadata.rb', line 133 def retrieval_monotonic_time @retrieval_monotonic_time end |
#status ⇒ Integer (readonly)
The HTTP status code
116 117 118 |
# File 'lib/google/cloud/env/compute_metadata.rb', line 116 def status @status end |
Instance Method Details
#google_flavor? ⇒ boolean
Returns true if the metadata-flavor is correct for Google Cloud
139 140 141 |
# File 'lib/google/cloud/env/compute_metadata.rb', line 139 def google_flavor? headers["Metadata-Flavor"] == "Google" end |