Artifacts resource

Import the artifact resource module and instantiate an artifact-service client

[ ]:
from collections.abc import Iterator
from typing import Any

from peak.resources import artifacts

client: artifacts.Artifact = artifacts.get_client()

Create a new artifact resource by uploading a file

  • ArtifactInfo is the 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 .dockerfile. It is strongly advised that users use this parameter when generating artifacts, to avoid hitting any sort of file or size limit exception, either on the client or the server side.

[ ]:
artifact: dict[str, Any] = client.create_artifact(
    name="example_artifact",
    artifact={
        "path": "../examples",
        "ignore_files": [".dockerignore"],
    },
    description="Example artifact",
)

List all existing artifact(s) and iterate over them

[ ]:
artifacts_iterator: Iterator[dict[str, Any]] = client.list_artifacts()
artifacts_iterated: dict[str, Any] = next(artifacts_iterator)

Describe an existing artifact

[ ]:
existing_artifact: dict[str, Any] = client.describe_artifact(str(artifact["id"]))

Update an artifact resource with a new version by uploading a new file

[ ]:
artifact_v2: dict[str, int] = client.create_artifact_version(
    artifact_id=str(artifact["id"]),
    artifact={"path": "../examples", "ignore_files": [".dockerignore"]},
)

Update an artifact resource’s existing metadata

[ ]:
client.update_artifact(artifact_id=str(artifact["id"]), body={"name": "example-artifact-new"})

Download a versioned artifact from an existing artifact resource

[ ]:
client.download_artifact(artifact_id=str(artifact["id"]), download_path="artifact.zip", version=int("2"))

Delete an artifact version from an existing artifact resource

[ ]:
client.delete_artifact_version(artifact_id=str(artifact["id"]), version=int("2"))

Delete an artifact resource along with all its version(s)

[ ]:
client.delete_artifact(artifact_id=str(artifact["id"]))