Press Blocks
Only
workflow
blocks are supported, at the moment, sokind='workflow'
is assumed implicitly, this will change as proper support forpress
blocks are added.
Blocks client module.
- peak.press.blocks.get_client(session=None)
Returns a Workflow Block client.
Press Blocks Client
- class peak.press.blocks.Block(session=None)
Client class for interacting with Blocks.
- Parameters:
session (Session) –
- create_deployment(body)
Creates a new deployment from Block spec.
Uses the latest spec release if release version is not provided. For each Block kind, all Deployments must have unique names within a tenant.
- REFERENCE:
- Parameters:
body (Dict[str, str]) – Dictionary containing deployment metadata, spec ID, release version (optional, defaults to latest spec release) and revision info.
- Returns:
ID of the created Block deployment
- Return type:
Dict[str, str]
- Raises:
BadRequestException – The given parameters are invalid.
UnauthorizedException – The credentials are invalid.
ForbiddenException – The user does not have permission to perform the operation.
NotFoundException – The given workflow spec release does not exist.
UnprocessableEntityException – The server was unable to process the request.
InternalServerErrorException – The server encountered an unexpected condition that prevented it from fulfilling the request.
- create_spec(body, artifact=None, featured=None, scope=None, tenants=None)
Create a new Block spec.
For each Block kind, all Specs must have unique names within a tenant.
- REFERENCE:
- Parameters:
body (Dict[str, Any]) – Dictionary containing Block spec metadata and configuration.
artifact (ArtifactInfo | None) – 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. It is not required if an existing image and version is used for creating the spec.
featured (bool | None) – Whether to feature this spec. By default it is False.
scope (str | None) – Specify weather tenants can discover and deploy this spec. private restricts the spec to this tenant alone, public makes it available on all tenants and shared allows specifying what set of tenants can access and use this spec. By default it is private.
tenants (List[str] | None) – Given a shared scope, specify what other tenants can discover and deploy this spec.
- Returns:
Id of the created block spec.
- Return type:
Dict[str, str]
- Raises:
BadRequestException – The given parameters are invalid.
UnauthorizedException – The credentials are invalid.
ForbiddenException – The user does not have permission to perform the operation.
PayloadTooLargeException – The given artifact size exceeds maximum limit.
UnprocessableEntityException – The server was unable to process the request.
InternalServerErrorException – The server encountered an unexpected condition that prevented it from fulfilling the request.
- create_spec_release(spec_id, body, artifact=None)
Publish a new release to an existing Block spec.
- REFERENCE:
- Parameters:
spec_id (str) – Id of the spec in which new release will be created.
body (Dict[str, Any]) – Dictionary containing updated release and config in the expected format.
artifact (ArtifactInfo | None) – 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. It is not required if an existing image and version is used for creating the spec.
- Returns:
Dictionary containing spec id and release version
- Return type:
Dict[str, str]
- Raises:
BadRequestException – The given parameters are invalid.
UnauthorizedException – The credentials are invalid.
ForbiddenException – The user does not have permission to perform the operation.
PayloadTooLargeException – The given artifact size exceeds maximum limit.
NotFoundException – The given app spec does not exist.
UnprocessableEntityException – The server was unable to process the request.
InternalServerErrorException – the server encountered an unexpected condition that prevented it from fulfilling the request.
- delete_deployment(deployment_id)
Deletes the Block deployment.
- REFERENCE:
- Parameters:
deployment_id (str) – The ID of the Block deployment to delete.
- Returns:
Empty dict object.
- Return type:
dict
- Raises:
BadRequestException – The given parameters are invalid.
UnauthorizedException – The credentials are invalid.
ForbiddenException – The user does not have permission to perform the operation.
NotFoundException – The given Block deployment does not exist.
UnprocessableEntityException – The server was unable to process the request.
InternalServerErrorException – the server encountered an unexpected condition that prevented it from fulfilling the request.
- delete_spec(spec_id)
Delete a Block Spec and all it’s associated releases.
- REFERENCE:
- Parameters:
spec_id (str) – The ID of the Block spec to delete.
- Returns:
Empty dict object.
- Return type:
dict
- Raises:
UnauthorizedException – The credentials are invalid.
ForbiddenException – The user does not have permission to perform the operation.
NotFoundException – The given Block spec does not exist.
UnprocessableEntityException – The server was unable to process the request.
InternalServerErrorException – the server encountered an unexpected condition that prevented it from fulfilling the request.
- describe_deployment(deployment_id)
Describes an existing Block deployment, also provides details of the latest revision.
- REFERENCE:
- Parameters:
deployment_id (str) – The ID of the Block deployment to retrieve.
- Returns:
Dictionary containing the details of the deployment.
- Return type:
Dict[str, Any]
- Raises:
BadRequestException – The given parameters are invalid.
UnauthorizedException – The credentials are invalid.
ForbiddenException – The user does not have permission to perform the operation.
NotFoundException – The given Block deployment does not exist.
InternalServerErrorException – The server encountered an unexpected condition that prevented it from fulfilling the request.
- describe_spec(spec_id)
Describes an existing Block spec and also provides details of the latest release.
- REFERENCE:
- Parameters:
spec_id (str) – The ID of the workflow spec to retrieve.
- Returns:
Dictionary containing the details of the spec.
- Return type:
Dict[str, Any]
- Raises:
BadRequestException – The given parameters are invalid.
UnauthorizedException – The credentials are invalid.
ForbiddenException – The user does not have permission to perform the operation.
NotFoundException – The given workflow spec does not exist.
InternalServerErrorException – The server encountered an unexpected condition that prevented it from fulfilling the request.
- describe_spec_release(spec_id, version)
Describe an existing spec release.
- REFERENCE:
- Parameters:
spec_id (str) – The ID of the block spec to retrieve.
version (str) – The release version of spec to retrieve in valid semantic versioning format.
- Returns:
Dictionary containing the details of the spec.
- Return type:
Dict[str, Any]
- Raises:
BadRequestException – The given parameters are invalid.
UnauthorizedException – The credentials are invalid.
ForbiddenException – The user does not have permission to perform the operation.
NotFoundException – The given block spec does not exist.
InternalServerErrorException – The server encountered an unexpected condition that prevented it from fulfilling the request.
- list_deployments(status: List[str] | None = None, name: str | None = None, title: str | None = None, sort: List[str] | None = None, page_size: int | None = None, page_number: int | None = None, *, return_iterator: Literal[False]) Dict[str, Any]
- list_deployments(status: List[str] | None = None, name: str | None = None, title: str | None = None, sort: List[str] | None = None, page_size: int | None = None, page_number: int | None = None, *, return_iterator: Literal[True] = True) Iterator[Dict[str, Any]]
Lists Block deployments ordered by creation date.
- REFERENCE:
- Parameters:
status (List[str] | None) – List of statuses to filter deployments.
name (str | None) – Only return deployments whose names begins with the query string.
title (str | None) – Only return deployments whose title begins with the query string.
sort (List[str] | None) – List of fields with desired ordering in the format [<field>:<order>, …], where order is one of [‘asc’, ‘desc’] and field is an ordered parameter within the response. Valid fields are createdAt, createdBy, name and title.
page_size (int | None) – Number of deployments to include 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 list of deployments 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 parameters are invalid.
UnauthorizedException – The credentials are invalid.
ForbiddenException – The user does not have permission to perform the operation.
UnprocessableEntityException – The server was unable to process the request.
InternalServerErrorException – The server encountered an unexpected condition that prevented it from fulfilling the request.
StopIteration – There are no more pages to list.
- list_spec_releases(spec_id: str, sort: List[str] | None = None, page_size: int | None = None, page_number: int | None = None, *, return_iterator: Literal[False]) Dict[str, Any]
- list_spec_releases(spec_id: str, sort: List[str] | None = None, page_size: int | None = None, page_number: int | None = None, *, return_iterator: Literal[True] = True) Iterator[Dict[str, Any]]
Get all releases of a Block spec (ordered by most recently created to oldest).
- REFERENCE:
- Parameters:
spec_id (str) – The ID of the Block spec to retrieve.
sort (List[str] | None) – List of fields with desired ordering in the format [<field>:<order>, …], where order is one of [‘asc’, ‘desc’] and field is an ordered parameter within the response. Valid fields are createdAt and createdBy.
page_size (int | None) – Number of specs to include 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 list of releases 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 parameters are invalid.
UnauthorizedException – The credentials are invalid.
ForbiddenException – The user does not have permission to perform the operation.
NotFoundException – The given Block spec does not exist.
InternalServerErrorException – The server encountered an unexpected condition that prevented it from fulfilling the request.
StopIteration – There are no more pages to list.
- list_specs(status: List[str] | None = None, featured: bool | None = None, name: str | None = None, title: str | None = None, sort: List[str] | None = None, scope: List[str] | None = None, page_size: int | None = None, page_number: int | None = None, *, return_iterator: Literal[False]) Dict[str, Any]
- list_specs(status: List[str] | None = None, featured: bool | None = None, name: str | None = None, title: str | None = None, sort: List[str] | None = None, scope: List[str] | None = None, page_size: int | None = None, page_number: int | None = None, *, return_iterator: Literal[True] = True) Iterator[Dict[str, Any]]
Lists all published Block specs ordered by creation date. Returns info for the latest release for each spec.
- REFERENCE:
- Parameters:
status (List[str] | None) – List of statuses to filter specs.
featured (bool | None) – Whether to only return featured specs.
name (str | None) – Only return specs whose names begins with the query string.
title (str | None) – Only return specs whose title begins with the query string.
sort (List[str] | None) – List of fields with desired ordering in the format [<field>:<order>, …], where order is one of [‘asc’, ‘desc’] and field is an ordered parameter within the response, defaults to []. Valid fields are createdAt, createdBy, name and title.
scope (List[str] | None) – List of scopes to only return specs of those scopes. Valid values are private, public and shared.
page_size (int | None) – Number of specs to include 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 list of specs 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 parameters are invalid.
UnauthorizedException – The credentials are invalid.
ForbiddenException – The user does not have permission to perform the operation.
InternalServerErrorException – The server encountered an unexpected condition that prevented it from fulfilling the request.
StopIteration – There are no more pages to list.
- update_deployment_metadata(deployment_id, body)
Update the metadata of the Block deployment.
- REFERENCE:
- Parameters:
deployment_id (str) – ID of the Block deployment to update.
body (Dict[str, Any]) – Dictionary of the new deployment metadata.
- Returns:
Details of the updated deployment.
- Return type:
dict
- Raises:
BadRequestException – The given parameters are invalid.
UnauthorizedException – The credentials are invalid.
ForbiddenException – The user does not have permission to perform the operation.
NotFoundException – The given Workflow spec does not exist.
UnprocessableEntityException – The server was unable to process the request.
InternalServerErrorException – The server encountered an unexpected condition that prevented it from fulfilling the request.
- update_spec_metadata(spec_id, body)
Update the metadata and discoverability of a Block Spec.
- REFERENCE:
- Parameters:
spec_id (str) – ID of the spec to update
body (Dict[str, Any]) – Dictionary containing the new spec metadata
- Returns:
Dictionary containing the details of the updated spec.
- Return type:
dict
- Raises:
BadRequestException – The given parameters are invalid.
UnauthorizedException – The credentials are invalid.
ForbiddenException – The user does not have permission to perform the operation.
NotFoundException – The given Workflow spec does not exist.
UnprocessableEntityException – The server was unable to process the request.
InternalServerErrorException – The server encountered an unexpected condition that prevented it from fulfilling the request.