Skip to content

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 by fetch_data().
  • _config (RepositoryConfig) – Describes which endpoint the repository fetches its data from.
  • _logger (Logger) – Logger of this repository, created lazily on first access through the logger property as a child of the client logger.

Functions:

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:

fetch_data¤

fetch_data()

Fetch new data and update the repository

logger¤

logger: logging.Logger

Gets the client logger

raise_modification_error¤

raise_modification_error(response)

Raise an exception if needed

Comments