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.
- Parameters
client (
google.cloud.runtimeconfig.client.Client
) – A client which holds credentials and project configuration for the config (which requires a project).name (str) – The name of the config.
- property client¶
The client bound to this config.
- property description¶
Description of the config object.
- Return type
str, or
NoneType
- Returns
the description (None until set from the server).
- property full_name¶
Fully-qualified name of this variable.
Example:
projects/my-project/configs/my-config
- Return type
- 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
- Return type
- 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.
- 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 thepages
property of the returned iterator instead of manually passing the token.client (
Client
) – (Optional) The client to use. If not passed, falls back to theclient
stored on the current config.
- Return type
- Returns
Iterator of
Variable
belonging to this project.
- property path¶
URL path for the config’s APIs.
- Return type
- Returns
The URL path based on project and config names.
- property project¶
Project bound to the config.
- Return type
- 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.
- 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
- Returns
The variable object created.