cmem_client.repositories.protocols.create_item¤
Protocol interface for repository item creation operations.
This module defines the CreateItemProtocol that repositories can implement to provide item creation capabilities. It includes comprehensive error handling for different API response formats and automatic repository refresh after successful creation.
The protocol handles both DataIntegration (build) and DataPlatform (explore) API error formats, providing consistent error reporting across different Corporate Memory components.
Classes:
- CreateConfig – Abstract base class for repository item creation configurations.
- CreateItemProtocol – Protocol which allows for creation of new items
Attributes:
CreateConfig¤
Bases: Model, ABC
Abstract base class for repository item creation configurations.
Attributes:
- model_config –
CreateItemConfig_contra¤
CreateItemConfig_contra = TypeVar('CreateItemConfig_contra', bound=CreateConfig, contravariant=True)
CreateItemProtocol¤
Bases: Protocol[ItemType, CreateItemConfig_contra]
Protocol which allows for creation of new items
Attributes:
- _client (
Client) – Corporate Memory client used for the HTTP requests of this repository. - _dict (
dict[str, ItemType]) – Cached contents of the repository, mapping the key of each item to the item itself. Backs the Mapping interface and is populated byfetch_data(). - _config (
RepositoryConfig) – Describes which endpoint the repository fetches its data from. - _logger (
Logger) – Logger of this repository, created lazily on first access through theloggerproperty as a child of the client logger.
Functions:
- create_item – Create (add) a new item to the repository
- fetch_data – Fetch new data and update the repository
- raise_modification_error – Raise an exception if needed
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
fetch_data¤
Fetch new data and update the repository
logger¤
Gets the client logger
raise_modification_error¤
Raise an exception if needed