Reference documentation and code samples for the Google Cloud Platform environment queries class Google::Cloud::Env::ComputeMetadata::Overrides.
A set of overrides for metadata access. This is used in
#overrides= and #with_overrides.
Generally, you should create and populate an overrides object, then
set it using one of those methods.
An empty overrides object that contains no data is interpreted as a
metadata server that does not respond and raises
MetadataServerNotResponding. Otherwise, the overrides specifies what
responses are returned for specified queries, and any query not
explicitly set will result in a 404.
Inherits
Object
Methods
#add
defadd(path,string,query:nil,headers:nil)->self
Add an override to the object, providing just a body string.
Parameters
path (String) — The key path (e.g. project/project-id)
string (String) — The response string to return.
query (Hash{String => String}) (defaults to: nil) — Any additional query
parameters for the request.
Returns
(self) — for chaining
#add_ping
defadd_ping()->self
Add an override for the ping request.
Returns
(self) — for chaining
#add_response
defadd_response(path,response,query:nil)->self
Add an override to the object, providing a full response.
Parameters
path (String) — The key path (e.g. project/project-id)
response (Response) — The response object to return.
query (Hash{String => String}) (defaults to: nil) — Any additional query
parameters for the request.
Returns
(self) — for chaining
#clear
defclear()->self
Clear all data from these overrides
Returns
(self) — for chaining
#empty?
defempty?()->true,false
Returns true if there is at least one override present
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-09 UTC."],[],[],null,["# Google Cloud Platform environment queries - Class Google::Cloud::Env::ComputeMetadata::Overrides (v2.3.1)\n\nVersion latestkeyboard_arrow_down\n\n- [2.3.1 (latest)](/ruby/docs/reference/google-cloud-env/latest/Google-Cloud-Env-ComputeMetadata-Overrides)\n- [2.3.0](/ruby/docs/reference/google-cloud-env/2.3.0/Google-Cloud-Env-ComputeMetadata-Overrides)\n- [2.2.2](/ruby/docs/reference/google-cloud-env/2.2.2/Google-Cloud-Env-ComputeMetadata-Overrides) \nReference documentation and code samples for the Google Cloud Platform environment queries class Google::Cloud::Env::ComputeMetadata::Overrides.\n\nA set of overrides for metadata access. This is used in\n[#overrides=](/ruby/docs/reference/google-cloud-env/latest/Google-Cloud-Env-ComputeMetadata#Google__Cloud__Env__ComputeMetadata_overrides__instance_ \"Google::Cloud::Env::ComputeMetadata#overrides= (method)\") and [#with_overrides](/ruby/docs/reference/google-cloud-env/latest/Google-Cloud-Env-ComputeMetadata#Google__Cloud__Env__ComputeMetadata_with_overrides_instance_ \"Google::Cloud::Env::ComputeMetadata#with_overrides (method)\").\nGenerally, you should create and populate an overrides object, then\nset it using one of those methods.\n\n\n\u003cbr /\u003e\n\nAn empty overrides object that contains no data is interpreted as a\nmetadata server that does not respond and raises\nMetadataServerNotResponding. Otherwise, the overrides specifies what\nresponses are returned for specified queries, and any query not\nexplicitly set will result in a 404. \n\nInherits\n--------\n\n- Object\n\nMethods\n-------\n\n### #add\n\n def add(path, string, query: nil, headers: nil) -\u003e self\n\nAdd an override to the object, providing just a body string. \n**Parameters**\n\n- **path** (String) --- The key path (e.g. `project/project-id`)\n- **string** (String) --- The response string to return.\n- **query** (Hash{String =\\\u003e String}) *(defaults to: nil)* --- Any additional query parameters for the request. \n**Returns**\n\n- (self) --- for chaining\n\n### #add_ping\n\n def add_ping() -\u003e self\n\nAdd an override for the ping request. \n**Returns**\n\n- (self) --- for chaining\n\n### #add_response\n\n def add_response(path, response, query: nil) -\u003e self\n\nAdd an override to the object, providing a full response. \n**Parameters**\n\n- **path** (String) --- The key path (e.g. `project/project-id`)\n- **response** ([Response](./Google-Cloud-Env-ComputeMetadata-Response)) --- The response object to return.\n- **query** (Hash{String =\\\u003e String}) *(defaults to: nil)* --- Any additional query parameters for the request. \n**Returns**\n\n- (self) --- for chaining\n\n### #clear\n\n def clear() -\u003e self\n\nClear all data from these overrides \n**Returns**\n\n- (self) --- for chaining\n\n### #empty?\n\n def empty?() -\u003e true, false\n\nReturns true if there is at least one override present \n**Returns**\n\n- (true, false)\n\n### #initialize\n\n def initialize() -\u003e Overrides\n\nCreate an empty overrides object. \n**Returns**\n\n- ([Overrides](./Google-Cloud-Env-ComputeMetadata-Overrides)) --- a new instance of Overrides\n\n### #lookup\n\n def lookup(path, query: nil) -\u003e String, nil\n\nLook up a response from the override data. \n**Parameters**\n\n- **path** (String) --- The key path (e.g. `project/project-id`)\n- **query** (Hash{String =\\\u003e String}) *(defaults to: nil)* --- Any additional query parameters for the request. \n**Returns**\n\n- (String) --- The response\n- (nil) --- if there is no data for the given query"]]