Artifact

Artifact client module.

peak.resources.artifacts.get_client(session=None)

Returns an Artifact client, If no session is provided, a default session is used.

Parameters:

session (Optional[Session]) – A Session Object. Default is None.

Returns:

the artifact client object

Return type:

Artifact

class peak.resources.artifacts.Artifact(session=None)

Artifact client class.

Parameters:

session (Session) –

create_artifact(name, artifact, description=None, source=None, scan=None, validate=None)

Create a new artifact.

REFERENCE:

🔗 API Documentation

Parameters:
  • name (str) – Name of the artifact.

  • artifact (ArtifactInfo) – Mapping of artifact attributes that specifies how the artifact will be generated, it accepts two keys path, which is required and ignore_files which is optional, and defaults to .dockerignore, it is strongly advised that users use ignore_files when generating artifacts to avoid copying any extra files in artifact.

  • description (str | None) – A brief description of the artifact.

  • source (str | None) – The source of the artifact.

  • scan (bool | None) – Whether to scan the artifact for vulnerabilities.

  • validate (bool | None) – Whether to validate the artifact. Source needs to be provided for the validation to work.

Returns:

Id and Version of the created artifact.

Return type:

Dict[str, Any]

Raises:
  • BadRequestException – The given request parameters are invalid.

  • UnauthorizedException – The credentials are invalid.

  • ForbiddenException – The user does not have permission to perform the operation.

  • PayloadTooLargeException – The artifact exceeds maximum size.

  • InternalServerErrorException – The server failed to process the request.

create_artifact_version(artifact_id, artifact, scan=None, validate=None)

Create a new version of the artifact.

REFERENCE:

🔗 API Documentation

Parameters:
  • artifact_id (str) – ID of the artifact for which a new version is to be created.

  • artifact (ArtifactInfo) – Mapping of artifact attributes that specifies how the artifact will be generated, it accepts two keys path, which is required and ignore_files which is optional, and defaults to .dockerignore, it is strongly advised that users use ignore_files when generating artifacts to avoid copying any extra files in artifact.

  • scan (bool | None) – Whether to scan the artifact for vulnerabilities.

  • validate (bool | None) – Whether to validate the artifact. Source needs to be present in the artifact for the validation to work.

Returns:

version number.

Return type:

Dict[str, int]

Raises:
  • BadRequestException – The given request parameters are invalid.

  • UnauthorizedException – The credentials are invalid.

  • ForbiddenException – The user does not have permission to perform the operation.

  • NotFoundException – The given image does not exist.

  • PayloadTooLargeException – The artifact exceeds maximum size.

  • InternalServerErrorException – The server failed to process the request.

delete_artifact(artifact_id)

Delete an artifact with all its versions.

REFERENCE:

🔗 API Documentation

Parameters:

artifact_id (str) – The ID of the artifact to delete.

Returns:

Empty dictionary object.

Return type:

dict

Raises:
  • BadRequestException – The given request parameters are invalid.

  • UnauthorizedException – The credentials are invalid.

  • ForbiddenException – The user does not have permission to perform the operation.

  • NotFoundException – The given image does not exist.

  • InternalServerErrorException – The server failed to process the request.

delete_artifact_version(artifact_id, version)

Delete a version of an artifact.

REFERENCE:

🔗 API Documentation

Parameters:
  • artifact_id (str) – ID of the artifact.

  • version (int) – Artifact version number to delete.

Returns:

Empty dict object.

Return type:

dict

Raises:
  • BadRequestException – The given request parameters are invalid.

  • UnauthorizedException – The credentials are invalid.

  • ForbiddenException – The user does not have permission to perform the operation.

  • NotFoundException – The given image does not exist.

  • UnprocessableEntityException – The server was unable to process the request.

  • InternalServerErrorException – The server failed to process the request.

describe_artifact(artifact_id, page_number=None, page_size=None)

Retrieve details of a specific artifact with list of its versions.

REFERENCE:

🔗 API Documentation

Parameters:
  • artifact_id (str) – The ID of the artifact to retrieve.

  • page_number (int | None) – The page number to retrieve.

  • page_size (int | None) – The number of versions per page.

Returns:

a dictionary containing the details of the artifact.

Return type:

Dict[str, Any]

Raises:
  • BadRequestException – The given request parameters are invalid.

  • UnauthorizedException – The credentials are invalid.

  • ForbiddenException – The user does not have permission to perform the operation.

  • NotFoundException – The given image does not exist.

  • InternalServerErrorException – The server failed to process the request.

download_artifact(artifact_id, download_path, version=None)

Download a version of the artifact.

REFERENCE:

🔗 API Documentation

Parameters:
  • artifact_id (str) – ID of the artifact to download.

  • download_path (str) – Path (including filename) where the downloaded file will be stored.

  • version (int | None) – Artifact version to download. If no version is given then latest version is downloaded.

Raises:
  • BadRequestException – The given request parameters are invalid.

  • UnauthorizedException – The credentials are invalid.

  • ForbiddenException – The user does not have permission to perform the operation.

  • NotFoundException – The given image does not exist.

  • InternalServerErrorException – The server failed to process the request.

Return type:

None

list_artifacts(page_size: int | None = None, page_number: int | None = None, *, return_iterator: Literal[False]) Dict[str, Any]
list_artifacts(page_size: int | None = None, page_number: int | None = None, *, return_iterator: Literal[True] = True) Iterator[Dict[str, Any]]

Retrieve a list of artifacts.

REFERENCE:

🔗 API Documentation

Parameters:
  • page_size (int | None) – The number of artifacts per page.

  • page_number (int | None) – The page number to retrieve. Only used when return_iterator is False.

  • return_iterator (bool) – Whether to return an iterator object or a list of artifacts, defaults to True.

Returns:

an iterator object which returns an element per iteration, until there are no more elements to return. If return_iterator is set to False, a dictionary containing the list and pagination details is returned instead.

Set return_iterator to True if you want automatic client-side pagination, or False if you want server-side pagination.

Return type:

Iterator[Dict[str, Any]] | Dict[str, Any]

Raises:
  • BadRequestException – The given request parameters are invalid.

  • UnauthorizedException – The credentials are invalid.

  • ForbiddenException – The user does not have permission to perform the operation.

  • InternalServerErrorException – The server failed to process the request.

update_artifact(artifact_id, body)

Update an artifact’s metadata.

REFERENCE:

🔗 API Documentation

Parameters:
  • artifact_id (str) – ID of the artifact to be updated.

  • body (Dict[str, Any]) – dictionary containing new metadata for artifact.

Returns:

Empty dict object.

Return type:

dict

Raises:
  • BadRequestException – The given request parameters are invalid.

  • UnauthorizedException – The credentials are invalid.

  • ForbiddenException – The user does not have permission to perform the operation.

  • NotFoundException – The given image does not exist.

  • InternalServerErrorException – The server failed to process the request.