# Variables

0.37.0 (latest) 0.36.1 0.35.0 0.34.0 0.33.3 0.32.6 0.31.0 0.30.0 0.29.2 Create / interact with Google Cloud RuntimeConfig variables.

### google.cloud.runtimeconfig.variable.STATE_UNSPECIFIED()

The default variable state. See
<https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/v1beta1/projects.configs.variables#VariableState>

### google.cloud.runtimeconfig.variable.STATE_UPDATED()

Indicates the variable was updated, while variables.watch was executing.
See
<https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/v1beta1/projects.configs.variables#VariableState>

### google.cloud.runtimeconfig.variable.STATE_DELETED()

Indicates the variable was deleted, while [variables.watch](https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/v1beta1/projects.configs.variables/watch) was executing.
See
<https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/v1beta1/projects.configs.variables#VariableState>

### *class* google.cloud.runtimeconfig.variable.Variable(name, config)

Bases: [`object`](https://docs.python.org/3/library/functions.html#object)

A variable in the Cloud RuntimeConfig service.

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

- **Parameters**

  - **name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- The name of the variable. This corresponds to the
    unique path of the variable in the config.

  - **config** ([`google.cloud.runtimeconfig.config.Config`](https://docs.cloud.google.com/python/docs/reference/runtimeconfig/latest/config#google.cloud.runtimeconfig.config.Config)) -- The config to which this variable belongs.

#### *property* client()

The client bound to this variable.

#### create(client=None)

API call: create the variable via a POST request

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

- **Parameters**

  **client** ([`Client`](https://docs.cloud.google.com/python/docs/reference/runtimeconfig/latest/client#google.cloud.runtimeconfig.client.Client)) -- (Optional) The client to use. If not passed, falls back to the
  `client` stored on the variable's config.
- **Return type**

  [bool](https://docs.python.org/3/library/functions.html#bool)
- **Returns**

  True if the variable has been created, False on error.

#### exists(client=None)

API call: test for the existence of the variable via a GET request

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

- **Parameters**

  **client** ([`Client`](https://docs.cloud.google.com/python/docs/reference/runtimeconfig/latest/client#google.cloud.runtimeconfig.client.Client)) -- (Optional) The client to use. If not passed, falls back to the
  `client` stored on the variable's config.
- **Return type**

  [bool](https://docs.python.org/3/library/functions.html#bool)
- **Returns**

  True if the variable exists in Cloud RuntimeConfig.

#### *classmethod* from_api_repr(resource, config)

Factory: construct a Variable given its API representation

- **Parameters**

  - **resource** ([*dict*](https://docs.python.org/3/library/stdtypes.html#dict)) -- change set representation returned from the API.

  - **config** ([`google.cloud.runtimeconfig.config.Config`](https://docs.cloud.google.com/python/docs/reference/runtimeconfig/latest/config#google.cloud.runtimeconfig.config.Config)) -- The config to which this variable belongs.

- **Return type**

  `google.cloud.runtimeconfig.variable.Variable`
- **Returns**

  Variable parsed from `resource`.

#### *property* full_name()

Fully-qualified name of this variable.

Example:
`projects/my-project/configs/my-config/variables/my-var`

- **Return type**

  [str](https://docs.python.org/3/library/stdtypes.html#str)
- **Returns**

  The full name based on config and variable names.
- **Raises**

  [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError) if the variable is missing a name.

#### *property* path()

URL path for the variable's APIs.

- **Return type**

  [str](https://docs.python.org/3/library/stdtypes.html#str)
- **Returns**

  The URL path based on config and variable names.

#### reload(client=None)

API call: reload the variable via a `GET` request.

This method will reload the newest data for the variable.

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

- **Parameters**

  **client** ([`google.cloud.runtimeconfig.client.Client`](https://docs.cloud.google.com/python/docs/reference/runtimeconfig/latest/client#google.cloud.runtimeconfig.client.Client)) -- (Optional) The client to use. If not passed, falls back to the
  client stored on the current config.

#### *property* state()

Retrieve the state of the variable.

See
<https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/v1beta1/projects.configs.variables#VariableState>

- **Return type**

  [str](https://docs.python.org/3/library/stdtypes.html#str)
- **Returns**

  If set, one of "UPDATED", "DELETED", or defaults to
  "VARIABLE_STATE_UNSPECIFIED".

#### *property* text()

Text of the variable, as string.

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

- **Return type**

  str or `NoneType`
- **Returns**

  The text of the variable or `None` if the property
  is not set locally.

#### update(client=None)

API call: update the variable via a PUT request

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

- **Parameters**

  **client** ([`Client`](https://docs.cloud.google.com/python/docs/reference/runtimeconfig/latest/client#google.cloud.runtimeconfig.client.Client)) -- (Optional) The client to use. If not passed, falls back to the
  `client` stored on the variable's config.
- **Return type**

  [bool](https://docs.python.org/3/library/functions.html#bool)
- **Returns**

  True if the variable has been created, False on error.

#### *property* update_time()

Retrieve the timestamp at which the variable was updated.

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

- **Returns**

  `DatetimeWithNanoseconds`,
  [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime) or `NoneType`:
  Datetime object parsed from RFC3339 valid timestamp, or
  `None` if the property is not set locally.
- **Raises**

  [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) -- if value is not a valid RFC3339 timestamp

#### *property* value()

Value of the variable, as bytes.

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

- **Return type**

  bytes or `NoneType`
- **Returns**

  The value of the variable or `None` if the property
  is not set locally.