cmem_client.repositories.variables¤
Repository for the variables of DataIntegration projects.
Provides VariablesRepository for creating, updating and deleting project variables and
the execution variables of tasks. Project variables are keyed by
project_id:variable_name, execution variables by
project_id:task_id:variable_name, so a single repository spans the variables of all
projects and their tasks.
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
Create an execution variable on a task and read its value back:
>>> client.variables.create_item(
... Variable(
... name="limit", project_id="my-project", task_id="my-workflow", value="10", scope="execution"
... )
... )
>>> client.variables.get_item("my-project", "limit", task_id="my-workflow").value
See what still uses a variable, list every variable of the deployment and delete one:
Classes:
- VariableCreateConfig – Variable creation configuration.
- VariableDeleteConfig – Variable deletion configuration.
- VariableUpdateConfig – Variable update configuration.
- VariablesRepository – Repository for project variables, execution variables and global variables.
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, execution variables and global variables.
Manages the variables of all projects in the eccenca Corporate Memory DataIntegration
(Build) environment together with the execution variables of their tasks.
Project variables are stored with keys in the form project_id:variable_name,
execution variables with keys in the form project_id:task_id:variable_name.
The global variables are part of the repository as well, with their name as key. They are defined in the configuration of DataIntegration, so they are read-only and can neither be created, updated nor deleted.
Fetching all variables masks sensitive ones, their value is empty. Use
get_item() to read a single project or execution variable including its value.
Attributes:
- tasks (
dict[str, str]) – Labels of all tasks of all projects byproject_id:task_id, including tasks without execution variables, as of the last fetch. - errors (
dict[str, str]) – Errors the server reported for single variables on the last fetch, by variable ID. A variable has an error, e.g. if its template can not be resolved.
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 the global variables, those of all projects and the execution variables of their tasks.
- get_dependents – Get the variables and tasks which still use a variable.
- get_item – Get a single variable by project, name and optionally task.
- 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
create_item¤
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:
RepositoryModificationError– if an error occurs while creating the itemHTTPError– for any other http error
delete_all¤
Delete all items from the repository
delete_item¤
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:
RepositoryModificationError– if an error occurs while creating the itemHTTPError– for any other http error
errors¤
fetch_data¤
Fetch the global variables, those of all projects and the execution variables of their tasks.
Raises:
RepositoryReadError– If Build does not provide the variables in one request, because it is too old.
get_dependents¤
Get the variables and tasks which still use a variable.
A variable which is used cannot be deleted. The server reports only some of its dependents on a failed deletion, while this lists all of them.
Parameters:
- key (
str) – Combined variable key in the formatproject_id:variable_nameorproject_id:task_id:variable_name.
Returns:
VariableDependents– The variables and tasks which use the variable.
Raises:
HTTPStatusError– If the variable is not found or the request fails.
get_item¤
Get a single variable by project, name and optionally task.
Parameters:
- project_id (
str) – The project ID. - variable_name (
str) – The variable name. - task_id (
str | None) – The task ID of an execution variable. Omit it for a project variable.
Returns:
Variable– Variable model.
Raises:
HTTPStatusError– If the variable is not found or the request fails.
items¤
Get the items of the repository
keys¤
Get the keys of the repository
logger¤
Gets the client logger
raise_modification_error¤
Raise an exception if needed
tasks¤
update_item¤
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:
RepositoryModificationError– If the item does not exist or an error occurs.HTTPError– For any other HTTP error.
values¤
Get the values of the repository