Skip to content

cmem_client.components.marketplace¤

eccenca Marketplace server integration.

This module provides the Marketplace component for interacting with the eccenca Marketplace server. The component handles package downloads, uploads and version queries, abstracting the marketplace REST API into a convenient Python interface.

The eccenca Marketplace is a central repository for distributing Corporate Memory packages, including vocabularies, ontologies, and Python plugins. This component enables automated package retrieval for installation and dependency resolution.

Classes:

  • Marketplace – Interface for eccenca Marketplace server operations.

Attributes:

LICENSE_HEADER¤

LICENSE_HEADER = 'x-eccenca-auth'

Header carrying the encrypted license on outbound marketplace requests.

MARKETPLACE_CACHE_DIR¤

MARKETPLACE_CACHE_DIR = xdg_cache_home() / 'eccenca-marketplace'

Marketplace¤

Marketplace(client, marketplace_url='https://eccenca.market', cache_dir=MARKETPLACE_CACHE_DIR, credentials=None, timeout=30, license_issuer_url=None)

Interface for eccenca Marketplace server operations.

The Marketplace component provides methods for downloading, uploading and deleting packages from the eccenca Marketplace server. It handles version resolution, package retrieval, and writing downloaded content to the filesystem.

Attributes:

  • _client (Client) – The Corporate Memory client instance used for HTTP communication.
  • _marketplace_url (HttpUrl) – Default marketplace server URL for package operations.
  • _cache_dir (Path | None) – Directory to use for cached downloads.

Functions:

Parameters:

  • client (Client) – The Corporate Memory client instance.
  • marketplace_url (HttpUrl | str) – Default marketplace server URL. Defaults to the public eccenca Marketplace.
  • cache_dir (Path | None) – Directory to use for cached downloads. If set to None, caching is disabled.
  • credentials (BaseCredentials | None) – The credentials used to authenticate with the marketplace server. Setting this attribute is needed for write operations on the server.
  • timeout (int) – The timeout to wait for a response from the marketplace server. Defaults to 30 seconds.
  • license_issuer_url (HttpUrl | str | None) – The local marketplace whose /api/session mints the encrypted license token attached as x-eccenca-auth to outbound requests. Defaults to client.config.url_marketplace (the marketplace bundled beside Corporate Memory).

cache_dir¤

cache_dir: Path | None

Get the cache directory.

credentials¤

credentials: BaseCredentials | None

Get the marketplace credentials.

delete_package¤

delete_package(package_id)

Delete a package from the marketplace server.

Parameters:

  • package_id (PackageIdentifier) – Marketplace package identifier of the package to be deleted.

Raises:

download_package¤

download_package(package_id, path=None, package_version=None, use_cache=True)

Download a package from the marketplace server to a specified directory.

Queries the marketplace server for available versions and downloads the requested package version. If no version is specified, downloads the latest available version. The package is saved with the naming convention: {package_id}-v{version}.cpa

If the package already exists in the cache, it will be reused instead of re-downloading.

Parameters:

  • package_id (PackageIdentifier) – Marketplace package identifier (e.g., “semanticarts-gist-vocab”).
  • path (Path | None) – Target directory where the package will be saved. If None, uses the cache directory. Must be a directory, not a file path.
  • package_version (PackageVersionIdentifier | None) – Specific version to download. If None, downloads the latest version.
  • use_cache (bool) – If True, use cached version if available instead of downloading.

Returns:

  • Path – The full file path where the package was saved (e.g.,
  • Path – /path/to/cache/semanticarts-gist-vocab-v13.0.0.cpa).

Raises:

  • MarketplaceReadError – If the marketplace server request fails or the package/version is not found.

get_available_packages¤

get_available_packages()

Get the available packages from the marketplace server.

get_marketplace_keycloak_token¤

get_marketplace_keycloak_token(credentials=None)

Get the marketplace keycloak token from the marketplace server provided keycloak instance.

This method first fetches the keycloak token URL needed from the marketplace server. After this it fetches a token with the given credentials and provides it for further authentication of protected routes.

When no credentials parameter is given, it uses the class attribute of the marketplace component.

Parameters:

  • credentials (BaseCredentials | None) – Marketplace keycloak credentials.

Returns:

  • str – The marketplace keycloak token.

Raises:

get_versions_from_package¤

get_versions_from_package(package_id)

Get the available versions of a package from the marketplace server.

Parameters:

  • package_id (PackageIdentifier) – Marketplace package identifier.

Returns:

  • list[PackageVersionIdentifier] – List of package versions available, newest first.

Raises:

http¤

http: httpx.Client

Get the HTTP client instance for making API requests.

Returns the configured HTTP client, creating it lazily on first access. The client is pre-configured with the timeout value. Authentication headers are added per-request by the individual methods that require them.

Returns:

  • Client – The httpx.Client instance configured for the marketplace component.

license_issuer_url¤

license_issuer_url: HttpUrl

Get the local marketplace URL used as the license-token issuer.

logger¤

logger = logging.getLogger(f'{self._client.logger.name}.{self.__class__.__name__}')

marketplace_url¤

marketplace_url: HttpUrl

Get the marketplace server URL.

timeout¤

timeout: int

Get the marketplace timeout.

upload_package¤

upload_package(package_id, path)

Upload a local package to the marketplace server.

Parameters:

  • package_id (PackageIdentifier) – Marketplace package identifier of the package to be uploaded.
  • path (Path) – Path of the package to be uploaded. Must be a valid .cpa file.

Raises:

Comments