cmem_client.repositories.rule_blocks¤
Rule block repository.
Rule blocks are listed through the generic task search endpoint. Because
TaskSearchRepository.fetch_data already requests task parameters, the search
response carries the complete ruleBlockModel including the declared input
ports, so no additional request is needed to report them.
Classes:
- RuleBlockDeleteConfig – Rule block deletion configuration.
- RuleBlocksRepository – Repository for rule blocks.
RuleBlockDeleteConfig¤
Bases: DeleteConfig
Rule block deletion configuration.
remove_dependent_tasks maps to the required removeDependentTasks
query parameter of the task delete endpoint. When true, DataIntegration
deletes every task that directly or indirectly references the rule block.
When false, referencing tasks are left behind holding a dangling reference,
which DataIntegration reports nowhere - callers are expected to check for
dependents themselves before passing false.
Attributes:
- model_config –
- remove_dependent_tasks (
bool) –
model_config¤
remove_dependent_tasks¤
RuleBlocksRepository¤
Bases: TaskSearchRepository, DeleteItemProtocol
Repository for rule blocks.
Functions:
- create_item – Create a new rule block in a project.
- delete_all – Delete all items from the repository
- delete_item – Delete an item from the repository
- evaluate – Evaluate a rule block against the input examples stored with it.
- fetch_data – Fetch a list from the DI task search endpoint via a type adapter.
- from_task_response – Reshape a task detail response into the canonical RuleBlock structure.
- get_item – Get full rule block details including metadata timestamps.
- get_task – Get full task details from the API.
- items – Get the items of the repository
- keys – Get the keys of the repository
- update_item – Replace an existing rule block with the given one.
- values – Get the values of the repository
Attributes:
- logger (
Logger) – Gets the client logger
create_item¤
Create a new rule block in a project.
Parameters:
- item (
RuleBlock) – RuleBlock withproject_id,id,metadataand optionallydata.rule_block_model.
Returns:
RuleBlock– The created rule block, read back from the server.
Raises:
HTTPStatusError– If the creation request fails.
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
evaluate¤
Evaluate a rule block against the input examples stored with it.
Both the project and the rule block task must exist; the endpoint is task-scoped and there is no project-free evaluation mode.
Parameters:
- project_id (
str) – The project ID. - rule_block_id (
str) – The rule block ID. - model (
RuleBlockModel) – The rule block model to evaluate.
Returns:
list[Any]– One result entry per stored input example.
Raises:
HTTPStatusError– If the project or rule block does not exist.
fetch_data¤
Fetch a list from the DI task search endpoint via a type adapter.
from_task_response¤
Reshape a task detail response into the canonical RuleBlock structure.
The task detail endpoint nests the model under data.parameters. It is
requested without labels, because with labels every parameter value is
wrapped into an additional value object.
Parameters:
- data (
dict[str, Any]) – The JSON response of the task detail endpoint.
Returns:
RuleBlock– The rule block with theruleBlockModelparameter moved underdata.
get_item¤
Get full rule block details including metadata timestamps.
Parameters:
- project_id (
str) – The project ID. - rule_block_id (
str) – The rule block ID.
Returns:
RuleBlock– RuleBlock model with the full model and metadata.
Raises:
HTTPStatusError– If the rule block is not found.
get_task¤
Get full task details from the API.
Parameters:
- project_id (
str) – The project ID. - task_id (
str) – The task ID. - with_labels (
bool) – Whether to include labels in the response.
Returns:
TaskResponse– The full task details as a TaskResponse model.
items¤
Get the items of the repository
keys¤
Get the keys of the repository
logger¤
Gets the client logger
update_item¤
Replace an existing rule block with the given one.
Parameters:
- item (
RuleBlock) – RuleBlock withproject_id,id,metadataanddata.rule_block_model.
Raises:
HTTPStatusError– If the update request fails.
values¤
Get the values of the repository