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:
Classes:
- ProjectImportStatus – Response of the project import status endpoint.
- ProjectsCreateConfig – Project Create Configuration.
- ProjectsDeleteConfig – Project Delete Configuration.
- ProjectsExportConfig – Project Export Configuration.
- ProjectsImportConfig – Project Import Configuration.
- ProjectsRepository – Repository for Build (DataIntegration) projects.
ProjectImportStatus¤
Bases: Model
Response of the project import status endpoint.
Attributes:
- project_id (
str) – Identifier of the imported project, sent asprojectId. - success (
bool | None) – Whether the import finished successfully. None while the import is still running, which is whatimport_item()polls on. - failure_message (
str | None) – Reason the import failed, sent asfailureMessage. Only set when the import failed.
failure_message¤
model_config¤
project_id¤
success¤
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.xmlZipincludes the project resources,xmlZipWithoutResourcesomits 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 asexportGroups. - export_user_data (
bool) – If True, include user data in the export. Sent asexportUserData.
export_user_data¤
extract_project_zip¤
include_access_conditions¤
marshalling_plugin¤
model_config¤
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 asimportGroups.
include_access_conditions¤
model_config¤
use_archive_handler¤
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:
- create_item – Create (add) a new item to the repository
- delete_all – Delete all items from the repository
- delete_item – Delete an item from the repository
- export_item – Export an item from the repository to a file path.
- fetch_data – Fetch simple list from a JSON endpoint via a type adapter
- get_failed_tasks_report – Get all failed tasks from project from its ID
- import_item – Import an exported file to the repository
- items – Get the items of the repository
- keys – Get the keys of the repository
- raise_modification_error – Raise an exception if needed
- reload_project – Reload all task from project from its ID
- values – Get the values of the repository
Attributes:
- logger (
Logger) – Gets the client logger
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
delete_all¤
Delete all items from the repository
delete_item¤
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:
RepositoryModificationError– if an error occurs while creating the itemHTTPError– for any other http error
export_item¤
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:
RepositoryItemNotFoundError– If the specified item key is not found.RepositoryReadError– If there’s an error during export or path mismatch.
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 all failed tasks from project from its ID
import_item¤
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¤
Get the items of the repository
keys¤
Get the keys of the repository
logger¤
Gets the client logger
raise_modification_error¤
Raise an exception if needed
reload_project¤
Reload all task from project from its ID
values¤
Get the values of the repository