Google Cloud Platform environment queries - Class Google::Cloud::Env::ComputeMetadata::Overrides (v2.2.2)

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

def add(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

def add_ping() -> self

Add an override for the ping request.

Returns
  • (self) — for chaining

#add_response

def add_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

def clear() -> self

Clear all data from these overrides

Returns
  • (self) — for chaining

#empty?

def empty?() -> true, false

Returns true if there is at least one override present

Returns
  • (true, false)

#initialize

def initialize() -> Overrides

Create an empty overrides object.

Returns
  • (Overrides) — a new instance of Overrides

#lookup

def lookup(path, query: nil) -> String, nil

Look up a response from the override data.

Parameters
  • path (String) — The key path (e.g. project/project-id)
  • query (Hash{String => String}) (defaults to: nil) — Any additional query parameters for the request.
Returns
  • (String) — The response
  • (nil) — if there is no data for the given query