Artifacts Client Methods#

This page lists all relevant methods for Dioptra Artifacts that are available via the Python Client.

Requirements#

Artifacts - CRUD methods#

After importing and initializing the client, these methods for creating, reading, updating, and deleting (CRUD) artifacts can be executed via client.artifacts.METHOD_NAME().

Create Artifact#

ArtifactsCollectionClient.create(group_id: str | int, job_id: str | int, artifact_uri: str, plugin_snapshot_id: str | int | None = None, task_id: str | int | None = None, description: str | None = None) dioptra.client.artifacts.T[source]#

Creates an artifact and associates with an existing Job.

Both plugin_snapshot_id and must be None or not None. If None, then the artifact is unavailable for use as input into another job and may only be downloaded.

Parameters
  • group_id – The id of the group that will own the artifact.

  • job_id – The id of the job that produced this artifact.

  • artifact_uri – The URI pointing to the location of the artifact.

  • plugin_snapshot_id – the plugin snapshot id of the plugin containing the artifact task used to serialize/deserialize the artifact, defaults to None.

  • task_id – the task id of the plugin artifact task used to serialize/deserialize the artifact, defaults to None

  • description – The description of the new artifact. Optional, defaults to None.

Returns

The response from the Dioptra API.

Get Artifacts#

ArtifactsCollectionClient.get(group_id: int | None = None, index: int = 0, page_length: int = 10, sort_by: str | None = None, descending: bool | None = None, search: str | None = None) dioptra.client.artifacts.T[source]#

Get a list of artifacts.

Parameters
  • group_id – The group id the artifacts belong to. If None, return artifacts from all groups that the user has access to. Optional, defaults to None.

  • index – The paging index. Optional, defaults to 0.

  • page_length – The maximum number of artifacts to return in the paged response. Optional, defaults to 10.

  • sort_by – The field to use to sort the returned list. Optional, defaults to None.

  • descending – Sort the returned list in descending order. Optional, defaults to None.

  • search – Search for artifacts using the Dioptra API’s query language. Optional, defaults to None.

Returns

The response from the Dioptra API.

Get One Artifact by ID#

ArtifactsCollectionClient.get_by_id(artifact_id: str | int) dioptra.client.artifacts.T[source]#

Get the artifact matching the provided id.

Parameters

artifact_id – The artifact id, an integer.

Returns

The response from the Dioptra API.

Modify Artifact#

ArtifactsCollectionClient.modify_by_id(artifact_id: str | int, plugin_snapshot_id: str | int | None = None, task_id: str | int | None = None, description: str | None = None) dioptra.client.artifacts.T[source]#

Modify the artifact matching the provided id.

Both plugin_snapshot_id and must be None or not None. If None, then the artifact is unavailable for use as input into another job and may only be downloaded.

Parameters
  • artifact_id – The artifact id, an integer.

  • plugin_snapshot_id – the plugin snapshot id of the plugin containing the artifact task used to serialize/deserialize the artifact. A value of None removes the association with the artifact task.

  • task_id – the task id of the plugin artifact task used to serialize/deserialize the artifact. A value of None removes the association with the artifact task.

  • description – The new description of the artifact. To remove the description, pass None.

Returns

The response from the Dioptra API.

Artifacts - Other Methods#

Get File Listing#

ArtifactsCollectionClient.get_files(artifact_id: str | int) dioptra.client.artifacts.T[source]#

Get the file listing for the artifact matching the provided id.

Parameters

artifact_id – The artifact id, an integer.

Returns

The response from the Dioptra API.

Download Artifact Contents#

ArtifactsCollectionClient.get_contents(artifact_id: str | int, file_type: dioptra.client.utils.FileTypes | None = None, artifact_path: str | None = None, output_dir: pathlib.Path | None = None, file_stem: str = 'contents') pathlib.Path[source]#

Get the contents of an artifact with the given artifact resource id.

Parameters
  • artifact_id – The artifact resource id, an integer.

  • file_type – if the artifact is a directory, this indicates the file type of the bundle that is returned, defaults to None. A value of None must be provided if the artifact is a file. If the artifact is a directory and None is provided, then a default of FileTypes.TAR_GZ is used.

  • artifact_path – if the artifact is a directory, then a value other than None indicates a path in the directory structure to retrieve. if the artifact is a file, None must be provided. All of the files for a directory artifact are returned if None is provided.

  • output_dir – the directory to save the downloaded artifact, defaults to None. If None, then the current working directory will be used.

  • file_stem – the file prefix or stem to use for the name of the downloaded file. Defaults to the value of “contents”.

Returns

A path to where the contents are downloaded.

Snapshots of Artifacts - Methods#

Methods belonging to the ArtifactsSnapshotCollectionClient are accessed via the snapshots property of the Artifacts Client (which points to ArtifactsSnapshotCollectionClient).

Example - Get Snapshots for an Artifact

Get Snapshots for an Artifact

client.artifacts.snapshots.get(artifact_id=1)

See available methods for the SnapshotsSubCollectionClient:

In addition to the standard snapshot methods, the Artifacts client includes specific methods for downloading snapshot content:

ArtifactsSnapshotCollectionClient.get_contents(artifact_id: str | int, artifact_snapshot_id: str | int, file_type: dioptra.client.utils.FileTypes | None = None, artifact_path: str | None = None, output_dir: pathlib.Path | None = None, file_stem: str = 'contents') pathlib.Path[source]#

Get the contents of an artifact with the given artifact resource id and artifact snapshot id.

Parameters
  • artifact_id – The artifact resource id, an integer.

  • artifact_snapshot_id – The artifact snapshot id, an integer.

  • file_type – if the artifact is a directory, this indicates the file type of the bundle that is returned, defaults to None. A value of None must be provided if the artifact is a file. If the artifact is a directory and None is provided, then a default of FileTypes.TAR_GZ is used.

  • artifact_path – if the artifact is a directory, then a value other than None indicates a path in the directory structure to retrieve. if the artifact is a file, None must be provided. All of the files for a directory artifact are returned if None is provided.

  • output_dir – the directory to save the downloaded artifact, defaults to None. If None, then the current working directory will be used.

  • file_stem – the file prefix or stem to use for the name of the downloaded file. Defaults to the value of “contents”.

Returns

A path to where the contents are downloaded.

See Also#