Imageο
image client module.
- peak.resources.images.get_client(session=None)ο
Returns an Image Management client, If no session is provided, a default session is used.
- class peak.resources.images.Image(session=None)ο
Image Client Class.
- Parameters:
session (Session) β
- create_image(body, artifact=None)ο
Create a new image.
- REFERENCE:
π API Documentation
- Parameters:
body (Dict[str, Any]) β Represents the body to be used to create image. Schema can be found below.
artifact (Optional[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. Required for image of source upload.
- Returns:
buildId, imageId, and versionId of the newly created image and the corresponding version.
- Return type:
Dict[str, Any]
- SCHEMA:
Images can be created by three ways:
{ "name": "string (required)", "type": "string (required)", "description": "string", "version": "string", "buildDetails": { "source": "string", "buildArguments": [ { "name": "string", "value": "string" } ], "secrets": [], "useCache": "boolean", "dockerfilePath": "string", "context": "string" }, }
{ "name": "string (required)", "type": "string (required)", "description": "string", "version": "string", "buildDetails": { "source": "string", "buildArguments": [ { "name": "string", "value": "string" } ], "secrets": [], "useCache": "boolean", "branch": "string", "repository": "string", "token": "string", "dockerfilePath": "string", "context": "string" }, }
{ "name": "string (required)", "type": "string (required)", "description": "string", "version": "string", "buildDetails": { "source": "string", "buildArguments": [ { "name": "string", "value": "string" } ], "secrets": [], "useCache": "boolean", "dockerfile": "string" }, }
- 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.
- Parameters:
body (Dict[str, Any]) β
artifact (ArtifactInfo | None) β
- Return type:
Dict[str, Any]
- create_or_update_image_version(body, artifact=None)ο
Create a new image or version if none exists, update version if exists based on image name and version combination.
- REFERENCE:
π API Documentation
- Parameters:
body (Dict[str, Any]) β Represents the body to be used to create image. Schema can be found below.
artifact (Optional[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.
- Returns:
- buildId, imageId, and versionId of the newly created image and the corresponding version when no image/version exists.
In case when image exists but version doesnβt it will return buildId and versionId of the newly created version along with imageId of the existing image. In case when image and version exists, it will return buildId for the updated version along with imageId and versionId of the existing image / version.
- Return type:
Dict[str, Any]
- SCHEMA:
{ "name": "string (required)", "type": "string (required)", "description": "string", "version": "string", "buildDetails": { "source": "string", "buildArguments": [ { "name": "string", "value": "string" } ], "secrets": [], "useCache": "boolean", "dockerfilePath": "string", "context": "string" }, }
{ "name": "string (required)", "type": "string (required)", "description": "string", "version": "string", "buildDetails": { "source": "string", "buildArguments": [ { "name": "string", "value": "string" } ], "secrets": [], "useCache": "boolean", "branch": "string", "repository": "string", "token": "string", "dockerfilePath": "string", "context": "string" }, }
{ "name": "string (required)", "type": "string (required)", "description": "string", "version": "string", "buildDetails": { "source": "string", "buildArguments": [ { "name": "string", "value": "string" } ], "secrets": [], "useCache": "boolean", "dockerfile": "string" }, }
- 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.
- Parameters:
body (Dict[str, Any]) β
artifact (ArtifactInfo | None) β
- Return type:
Dict[str, Any]
- create_version(image_id, body, artifact=None)ο
Create a new version.
- REFERENCE:
π API Documentation
- Parameters:
image_id (int) β The ID of the image for which we have to create a new version.
body (Dict[str, Any]) β Represents the body to be used to create image version. Schema can be found below.
artifact (Optional[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.
- Returns:
imageId, buildId, versionId and autodeploymentId of the newly created version.
- Return type:
Dict[str, Any]
- SCHEMA:
Image versions can be created by three ways:
{ "name": "string (required)", "type": "string (required)", "description": "string", "version": "string", "buildDetails": { "source": "string", "buildArguments": [ { "name": "string", "value": "string" } ], "secrets": [], "useCache": "boolean", "dockerfilePath": "string", "context": "string" }, }
{ "name": "string (required)", "type": "string (required)", "description": "string", "version": "string", "buildDetails": { "source": "string", "buildArguments": [ { "name": "string", "value": "string" } ], "secrets": [], "useCache": "boolean", "branch": "string", "repository": "string", "token": "string", "dockerfilePath": "string", "context": "string" }, }
{ "name": "string (required)", "type": "string (required)", "description": "string", "version": "string", "buildDetails": { "source": "string", "buildArguments": [ { "name": "string", "value": "string" } ], "secrets": [], "useCache": "boolean", "dockerfile": "string" }, }
- 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.
- Parameters:
image_id (int) β
body (Dict[str, Any]) β
artifact (ArtifactInfo | None) β
- Return type:
Dict[str, Any]
- delete_image(image_id)ο
Delete an Image. All the versions in the image will first go into deleting state before actually being deleted.
- REFERENCE:
π API Documentation
- Parameters:
image_id (int) β The ID of the image to delete.
- Returns:
Empty dictionary object.
- Return type:
dict
- Raises:
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.
- delete_version(image_id, version_id)ο
Delete an Image Version.
- REFERENCE:
π API Documentation
- Parameters:
image_id (int) β The ID of the image to delete.
version_id (int) β The ID of the version to delete.
- Returns:
Empty dictionary object.
- Return type:
dict
- Raises:
UnauthorizedException β The credentials are invalid.
ForbiddenException β The user does not have permission to perform this 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.
- delete_versions(image_id, version_ids)ο
Delete given versions for an image. All the versions will first go into deleting state before they and all their associated resources are deleted.
- REFERENCE:
π API Documentation
- Parameters:
image_id (int) β The ID of the image to delete.
version_ids (List[int]) β The IDs of the versions to delete.
- Returns:
Empty dictionary object.
- Return type:
dict
- Raises:
UnauthorizedException β The credentials are invalid.
ForbiddenException β The user does not have permission to perform this 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_image(image_id)ο
Retrieve details of a specific image and its latest version.
- REFERENCE:
π API Documentation
- Parameters:
image_id (int) β The ID of the image to retrieve.
- Returns:
A dictionary containing the details of the image and its latest version.
- 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.
UnprocessableEntityException β The server was unable to process the request.
InternalServerErrorException β The server failed to process the request.
- describe_version(image_id, version_id)ο
Retrieve details of a specific version.
- REFERENCE:
π API Documentation
- Parameters:
image_id (int) β The ID of the image to retrieve.
version_id (int) β The ID of the image to retrieve.
- Returns:
a dictionary containing the details of the version.
- 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.
UnprocessableEntityException β The server was unable to process the request.
InternalServerErrorException β The server failed to process the request.
- get_build_logs(image_id, build_id, next_token=None, save=False, file_name=None)ο
Retrieve or save the logs of an image build.
- REFERENCE:
π API Documentation
- Parameters:
image_id (int) β The ID of the image.
build_id (int) β The ID of the image build.
next_token (str | None) β The token to retrieve the next set of logs.
save (bool) β Whether to save the logs to a file. Defaults to False.
file_name (str | None) β File name or path where the contents should be saved. Default file name is image_build_logs_{image_id}_{build_id}.log.
- Returns:
A dictionary containing the logs of the build. If save is set to True, the signed URL to download the logs is returned and the logs are saved to a file.
- 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 this operation.
NotFoundException β The given image or build does not exist.
InternalServerErrorException β The server failed to process the request.
- list_image_builds(image_id: int, date_from: str | None = None, date_to: str | None = None, page_size: int | None = None, page_number: int | None = None, count: int | None = None, version_ids: List[str] | None = None, build_status: List[str] | None = None, *, return_iterator: Literal[False]) Dict[str, Any] ο
- list_image_builds(image_id: int, date_from: str | None = None, date_to: str | None = None, page_size: int | None = None, page_number: int | None = None, count: int | None = None, version_ids: List[str] | None = None, build_status: List[str] | None = None, *, return_iterator: Literal[True] = True) Iterator[Dict[str, Any]]
Lists image builds.
- REFERENCE:
π API Documentation
- Parameters:
image_id (int) β ID of the image to fetch image build history.
date_from (str | None) β The date after which the image builds should be included (in ISO format). It is 90 days from current date by default.
date_to (str | None) β The date till which the image builds should be included (in ISO format). It is current date by default.
page_size (int | None) β Number of builds per page.
page_number (int | None) β Page number to retrieve. Only used when return_iterator is False.
count (int | None) β Number of builds required (Ordered by latest to earliest). For example, if 5 is provided, it will return last 5 builds. It is -1 by default which means it will return all the available builds within the given dates.
version_ids (List[str] | None) β List of version ids to filter builds.
build_status (List[str] | None) β List of build statuses to filter builds. Valid values are building, failed, success, stopped, stopping.
return_iterator (bool) β Whether to return an iterator object or a dictionary of list of image builds. 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 β 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.
- list_image_versions(image_id: int, page_size: int | None = None, page_number: int | None = None, version: str | None = None, status: List[str] | None = None, last_build_status: List[str] | None = None, tags: List[str] | None = None, *, return_iterator: Literal[False]) Dict[str, Any] ο
- list_image_versions(image_id: int, page_size: int | None = None, page_number: int | None = None, version: str | None = None, status: List[str] | None = None, last_build_status: List[str] | None = None, tags: List[str] | None = None, *, return_iterator: Literal[True] = True) Iterator[Dict[str, Any]]
Retrieve a list of image versions.
- REFERENCE:
π API Documentation
- Parameters:
image_id (int) β The Image id for which we want to get versions.
page_size (int | None) β The number of images per page.
page_number (int | None) β The page number to retrieve. Only used when return_iterator is False.
version β (str | None): Search by version.
status (List[str] | None) β Filter versions on the basis of their status. Valid values are not-ready, ready, in-use, deleting, delete-failed.
last_build_status (List[str] | None) β Filter out on the basis of last build status of version. Valid values are building, failed, success, stopped, stopping.
tags (List[str] | None) β Filter out on the basis of the tags attached to the version.
return_iterator (bool) β Whether to return an iterator object or list of images for a specified page number, 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 this operation.
InternalServerErrorException β The server failed to process the request.
- list_images(page_size: int | None = None, page_number: int | None = None, name: str | None = None, status: List[str] | None = None, scope: List[str] | None = None, last_build_status: List[str] | None = None, tags: List[str] | None = None, *, return_iterator: Literal[False]) Dict[str, Any] ο
- list_images(page_size: int | None = None, page_number: int | None = None, name: str | None = None, status: List[str] | None = None, scope: List[str] | None = None, last_build_status: List[str] | None = None, tags: List[str] | None = None, *, return_iterator: Literal[True] = True) Iterator[Dict[str, Any]]
Retrieve the list of images.
- REFERENCE:
π API Documentation
- Parameters:
page_size (int | None) β The number of images per page.
page_number (int | None) β The page number to retrieve. Only used when return_iterator is False.
name β (str | None): Image Name or version to search for.
status (List[str] | None) β Filter images on the basis of the status of the latest version. Valid values are not-ready, ready, in-use, deleting, delete-failed.
scope (List[str] | None) β Filter out on the basis of the type of the image - global or custom.
last_build_status (List[str] | None) β Filter out on the basis of last build status of the latest version. Valid values are building, failed, success, stopped, stopping.
tags (List[str] | None) β Filter out on the basis of the tags attached to the latest version.
return_iterator (bool) β Whether to return an iterator object or list of images for a specified page number, 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_version(image_id, version_id, body, artifact=None)ο
Update an existing image version.
- REFERENCE:
π API Documentation
- Parameters:
image_id (int) β The ID of the image to update.
version_id (int) β The ID of the version to update.
body (Dict[str, Any]) β Represents the body to be used to update image version. Schema can be found below.
artifact (Optional[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.
- Returns:
imageId, buildId, versionId and autodeploymentId of the updated version.
- Return type:
Dict[str, Any]
- SCHEMA:
{ "name": "string (required)", "type": "string (required)", "description": "string", "version": "string", "buildDetails": { "source": "string", "buildArguments": [ { "name": "string", "value": "string" } ], "secrets": [], "useCache": "boolean", "dockerfilePath": "string", "context": "string" }, }
{ "name": "string (required)", "type": "string (required)", "description": "string", "version": "string", "buildDetails": { "source": "string", "buildArguments": [ { "name": "string", "value": "string" } ], "secrets": [], "useCache": "boolean", "branch": "string", "repository": "string", "token": "string", "dockerfilePath": "string", "context": "string" }, }
{ "name": "string (required)", "type": "string (required)", "description": "string", "version": "string", "buildDetails": { "source": "string", "buildArguments": [ { "name": "string", "value": "string" } ], "secrets": [], "useCache": "boolean", "dockerfile": "string" }, }
- 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 or version does not exist.
PayloadTooLargeException β The artifact exceeds maximum size.
UnprocessableEntityException β The server was unable to process the request.
InternalServerErrorException β The server failed to process the request.
- Parameters:
image_id (int) β
version_id (int) β
body (Dict[str, Any]) β
artifact (ArtifactInfo | None) β
- Return type:
dict[str, str]