Skip to content

cmem_client.repositories.projects¤

Repository for managing DataIntegration projects.

Provides ProjectsRepository for creating, deleting, importing and exporting build projects, and for reloading a project and reading its failed task report.

Examples:

Create a project and list the projects of the workspace:

>>> from cmem_client.client import Client
>>> from cmem_client.models.project import Project
>>> client = Client.from_env()
>>> client.projects.create_item(
...     Project(name="my-project", meta_data={"label": "My Project"}),
...     skip_if_existing=True,
... )
>>> list(client.projects)

Export a project to a ZIP archive and reload it afterwards:

>>> from pathlib import Path
>>> client.projects.export_item(key="my-project", path=Path("my-project.zip"))
>>> client.projects.reload_project("my-project")

Find out which tasks of a project failed to load:

>>> for failed in client.projects.get_failed_tasks_report("my-project"):
...     print(failed)

Classes:

ProjectImportStatus¤

Bases: Model

Response of the project import status endpoint.

Attributes:

  • project_id (str) – Identifier of the imported project, sent as projectId.
  • success (bool | None) – Whether the import finished successfully. None while the import is still running, which is what import_item() polls on.
  • failure_message (str | None) – Reason the import failed, sent as failureMessage. Only set when the import failed.

failure_message¤

failure_message: str | None = Field(alias='failureMessage', default=None)

model_config¤

model_config = ConfigDict(extra='allow', populate_by_name=True)

project_id¤

project_id: str = Field(alias='projectId')

success¤

success: bool | None = None

ProjectsCreateConfig¤

Bases: CreateConfig

Project Create Configuration.

Attributes:

  • model_config

ProjectsDeleteConfig¤

Bases: DeleteConfig

Project Delete Configuration.

Attributes:

  • model_config

ProjectsExportConfig¤

Bases: ExportConfig

Project Export Configuration.

Attributes:

  • marshalling_plugin (Literal[‘xmlZip’, ‘xmlZipWithoutResources’]) – Export format plugin. xmlZip includes the project resources, xmlZipWithoutResources omits them.
  • extract_project_zip (bool) – If True, extract the exported archive into the given path as a directory instead of writing a single zip file.
  • include_access_conditions (bool) – If True, export the access conditions of the project. Sent as exportGroups.
  • export_user_data (bool) – If True, include user data in the export. Sent as exportUserData.

export_user_data¤

export_user_data: bool = True

extract_project_zip¤

extract_project_zip: bool = False

include_access_conditions¤

include_access_conditions: bool = False

marshalling_plugin¤

marshalling_plugin: Literal['xmlZip', 'xmlZipWithoutResources'] = 'xmlZip'

model_config¤

model_config = ConfigDict(extra='allow', populate_by_name=True)

ProjectsImportConfig¤

Bases: ImportConfig

Project Import Configuration.

Attributes:

  • use_archive_handler (bool) – Defaults to False here, unlike the base class, so the project archive is passed to the API as-is instead of being unpacked by the ArchiveHandler.
  • include_access_conditions (bool) – If True, import the access conditions contained in the archive. Sent as importGroups.

include_access_conditions¤

include_access_conditions: bool = False

model_config¤

model_config = ConfigDict(extra='allow', populate_by_name=True)

use_archive_handler¤

use_archive_handler: bool = False

ProjectsRepository¤

Bases: PlainListRepository, DeleteItemProtocol, CreateItemProtocol, ImportItemProtocol, ExportItemProtocol

Repository for Build (DataIntegration) projects.

This repository manages Build (DataIntegration) projects which are described with the Project model.

Functions:

Attributes:

  • logger (Logger) – Gets the client logger

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:

delete_all¤

delete_all()

Delete all items from the repository

delete_item¤

delete_item(key, skip_if_missing=False, configuration=None)

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:

export_item¤

export_item(key, path=None, replace=False, configuration=None)

Export an item from the repository to a file path.

Parameters:

  • key (str) – The key identifying the item to export.
  • path (Path | None) – The target file path for export. If None, a path will be generated.
  • replace (bool) – Whether to replace existing files at the target path.
  • configuration (ExportItemConfig_contra | None) – Optional configuration for export behavior.

Returns:

  • Path – The actual path where the item was exported.

Raises:

fetch_data¤

fetch_data()

Fetch simple list from a JSON endpoint via a type adapter

Use this method to fetch data when your result set is an array of objects.

get_failed_tasks_report¤

get_failed_tasks_report(project_id)

Get all failed tasks from project from its ID

import_item¤

import_item(path=None, key=None, on_conflict=ImportConflictPolicy.FAIL, configuration=None)

Import an exported file to the repository

By default, automatically handles zip files, directories, and single files using ImportItem model. Can be disabled by setting use_archive_handler=False in the configuration.

Returns:

  • str – The key of the imported item.

Raises:

  • RepositoryModificationError – If the item already exists and the conflict policy is FAIL, if the import type is not allowed for this repository, if the import request failed, or if the item is not present afterwards.

items¤

items()

Get the items of the repository

keys¤

keys()

Get the keys of the repository

logger¤

logger: logging.Logger

Gets the client logger

raise_modification_error¤

raise_modification_error(response)

Raise an exception if needed

reload_project¤

reload_project(project_id)

Reload all task from project from its ID

values¤

values()

Get the values of the repository

Comments