Skip to content

cmem_client.repositories.base.abc¤

Abstract base classes and configuration for CMEM repositories.

This module provides the foundational classes for building repositories in the CMEM client:

  • RepositoryConfig: Configuration class that defines component type, fetch paths, and data adapters
  • Repository: Abstract base class implementing a lazy-loading, read-only, dictionary-like interface for accessing CMEM resources with automatic data fetching and caching capabilities

Classes:

  • Repository – ABC of a lazy loading, read-only, dictionary-mimicking repository
  • RepositoryConfig – Configuration class for a read repository.

Attributes:

ItemType¤

ItemType = TypeVar('ItemType', bound=ReadRepositoryItem)

KeysViewType¤

KeysViewType = KeysView[str]

Repository¤

Repository(client)

Bases: ABC, Mapping

ABC of a lazy loading, read-only, dictionary-mimicking repository

Attributes:

  • _dict (dict[str, Repository[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().
  • _client (Client) – Corporate Memory client used for the HTTP requests of this repository.
  • _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:

  • fetch_data – Fetch new data and update the repository
  • items – Get the items of the repository
  • keys – Get the keys of the repository
  • values – Get the values of the repository

fetch_data¤

fetch_data()

Fetch new data and update the repository

items¤

items()

Get the items of the repository

keys¤

keys()

Get the keys of the repository

logger¤

logger: logging.Logger

Gets the client logger

values¤

values()

Get the values of the repository

RepositoryConfig¤

RepositoryConfig(component, fetch_data_path, fetch_data_adapter)

Configuration class for a read repository.

This class defines the essential configuration parameters needed to set up a repository that can fetch data from CMEM components.

Attributes:

  • component (Literal[‘build’, ‘explore’, ‘keycloak’]) – Which Corporate Memory API endpoint to address: build, explore or keycloak.
  • fetch_data_path (str) – API path used to retrieve the repository data.
  • fetch_data_adapter (TypeAdapter) – Pydantic TypeAdapter used to deserialize the API response.

component¤

component: Literal['build', 'explore', 'keycloak'] = component

fetch_data_adapter¤

fetch_data_adapter: TypeAdapter = fetch_data_adapter

fetch_data_path¤

fetch_data_path: str = fetch_data_path

Comments