As of January 1, 2020 this library no longer supports Python 2 on the latest released version. Library versions released prior to that date will continue to be available. For more information please visit Python 2 support on Google Cloud.

Configuration

Create / interact with Google Cloud RuntimeConfig configs.

class google.cloud.runtimeconfig.config.Config(client, name)[source]

Bases: object

A Config resource in the Cloud RuntimeConfig service.

This consists of metadata and a hierarchy of variables.

See https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/v1beta1/projects.configs

Parameters
property client

The client bound to this config.

property description

Description of the config object.

See https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/v1beta1/projects.configs#resource-runtimeconfig

Return type

str, or NoneType

Returns

the description (None until set from the server).

exists(client=None)[source]

Determines whether or not this config exists.

Parameters

client (Client) – (Optional) The client to use. If not passed, falls back to the client stored on the current config.

Return type

bool

Returns

True if the config exists in Cloud Runtime Configurator.

property full_name

Fully-qualified name of this variable.

Example: projects/my-project/configs/my-config

Return type

str

Returns

The full name based on project and config names.

Raises

ValueError if the config is missing a name.

get_variable(variable_name, client=None)[source]

API call: get a variable via a GET request.

This will return None if the variable doesn’t exist:

>>> from google.cloud import runtimeconfig
>>> client = runtimeconfig.Client()
>>> config = client.config('my-config')
>>> print(config.get_variable('variable-name'))
<Variable: my-config, variable-name>
>>> print(config.get_variable('does-not-exist'))
None
Parameters
  • variable_name (str) – The name of the variable to retrieve.

  • client (Client) – (Optional) The client to use. If not passed, falls back to the client stored on the current config.

Return type

google.cloud.runtimeconfig.variable.Variable or None

Returns

The variable object if it exists, otherwise None.

list_variables(page_size=None, page_token=None, client=None)[source]

API call: list variables for this config.

This only lists variable names, not the values.

See https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/v1beta1/projects.configs.variables/list

Parameters
  • page_size (int) – Optional. The maximum number of variables in each page of results from this request. Non-positive values are ignored. Defaults to a sensible value set by the API.

  • page_token (str) – Optional. If present, return the next batch of variables, using the value, which must correspond to the nextPageToken value returned in the previous response. Deprecated: use the pages property of the returned iterator instead of manually passing the token.

  • client (Client) – (Optional) The client to use. If not passed, falls back to the client stored on the current config.

Return type

Iterator

Returns

Iterator of Variable belonging to this project.

property path

URL path for the config’s APIs.

Return type

str

Returns

The URL path based on project and config names.

property project

Project bound to the config.

Return type

str

Returns

the project (derived from the client).

reload(client=None)[source]

API call: reload the config via a GET request.

This method will reload the newest data for the config.

See https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/v1beta1/projects.configs/get

Parameters

client (google.cloud.runtimeconfig.client.Client) – (Optional) The client to use. If not passed, falls back to the client stored on the current config.

variable(variable_name)[source]

Factory constructor for variable object.

Note

This will not make an HTTP request; it simply instantiates a variable object owned by this config.

Parameters

variable_name (str) – The name of the variable to be instantiated.

Return type

google.cloud.runtimeconfig.variable.Variable

Returns

The variable object created.