Skip to content

cmem_client.repositories.variables¤

Repository for the variables of DataIntegration projects.

Provides VariablesRepository for creating, updating and deleting project variables. Variables are keyed by the composite key project_id:variable_name, so a single repository spans the variables of all projects.

Examples:

Create a variable in a project and read its value back:

>>> from cmem_client.client import Client
>>> from cmem_client.models.variable import Variable
>>> client = Client.from_env()
>>> client.variables.create_item(
...     Variable(name="greeting", project_id="my-project", value="hello")
... )
>>> client.variables["my-project:greeting"].value
>>> client.variables.get_item("my-project", "greeting").value

List every variable of the deployment and delete one:

>>> list(client.variables)
>>> client.variables.delete_item("my-project:greeting")

Classes:

VariableCreateConfig¤

Bases: CreateConfig

Variable creation configuration.

Attributes:

  • model_config

VariableDeleteConfig¤

Bases: DeleteConfig

Variable deletion configuration.

Attributes:

  • model_config

VariableUpdateConfig¤

Bases: UpdateConfig

Variable update configuration.

Attributes:

  • model_config

VariablesRepository¤

Bases: Repository, DeleteItemProtocol, CreateItemProtocol, UpdateItemProtocol

Repository for project variables.

Manages project variables across all projects in the Corporate Memory DataIntegration (build) environment. Variables are fetched per project and stored with combined keys in the form project_id:variable_name.

Functions:

  • create_item – Create (add) a new item to the repository
  • delete_all – Delete all items from the repository
  • delete_item – Delete an item from the repository
  • fetch_data – Fetch all variables from all projects.
  • get_item – Get a single variable by project and name.
  • items – Get the items of the repository
  • keys – Get the keys of the repository
  • raise_modification_error – Raise an exception if needed
  • update_item – Update an existing item in the repository.
  • values – Get the values of the repository

Attributes:

  • logger (Logger) – Gets the client logger

create_item¤

create_item(item, skip_if_existing=False, configuration=None)

Create (add) a new item to the repository

Parameters:

  • item (ItemType) – The item to add to the repository
  • skip_if_existing (bool) – If true, creating already existing items will be ignored
  • configuration (CreateItemConfig_contra | None) – Optional configuration

Raises:

delete_all¤

delete_all()

Delete all items from the repository

delete_item¤

delete_item(key, skip_if_missing=False, configuration=None)

Delete an item from the repository

Parameters:

  • key (str) – The key of the item to delete
  • skip_if_missing (bool) – If True, it is ignored if the deleted item even exists
  • configuration (DeleteItemConfig) – Optional configuration for deletion

Raises:

fetch_data¤

fetch_data()

Fetch all variables from all projects.

get_item¤

get_item(project_id, variable_name)

Get a single variable by project and name.

Parameters:

  • project_id (str) – The project ID.
  • variable_name (str) – The variable name.

Returns:

Raises:

  • HTTPStatusError – If the variable is not found or the request fails.

items¤

items()

Get the items of the repository

keys¤

keys()

Get the keys of the repository

logger¤

logger: logging.Logger

Gets the client logger

raise_modification_error¤

raise_modification_error(response)

Raise an exception if needed

update_item¤

update_item(item, configuration=None)

Update an existing item in the repository.

Parameters:

  • item (ItemType) – The item to update in the repository.
  • configuration (UpdateItemConfig_contra | None) – Optional configuration for the update operation.

Raises:

values¤

values()

Get the values of the repository

Comments