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
.
Instance Attribute Summary collapse
-
#body ⇒ String
readonly
The HTTP response body.
-
#headers ⇒ Hash{String=>String}
readonly
The HTTP response headers.
-
#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.
104 105 106 107 108 |
# File 'lib/google/cloud/env/compute_metadata.rb', line 104 def initialize status, body, headers @status = status @body = body @headers = headers end |
Instance Attribute Details
#body ⇒ String (readonly)
The HTTP response body
120 121 122 |
# File 'lib/google/cloud/env/compute_metadata.rb', line 120 def body @body end |
#headers ⇒ Hash{String=>String} (readonly)
The HTTP response headers
126 127 128 |
# File 'lib/google/cloud/env/compute_metadata.rb', line 126 def headers @headers end |
#status ⇒ Integer (readonly)
The HTTP status code
114 115 116 |
# File 'lib/google/cloud/env/compute_metadata.rb', line 114 def status @status end |
Instance Method Details
#google_flavor? ⇒ boolean
Returns true if the metadata-flavor is correct for Google Cloud
132 133 134 |
# File 'lib/google/cloud/env/compute_metadata.rb', line 132 def google_flavor? headers["Metadata-Flavor"] == "Google" end |