Skip to content

Artifacts

get_artifact(project_name, repository_name, reference, page=1, page_size=10, with_tag=True, with_label=False, with_scan_overview=False, with_signature=False, with_immutable_status=False, with_accessory=False, mime_type='application/vnd.security.vulnerability.report; version=1.1') async

Get an artifact.

Parameters:

Name Type Description Default
project_name str

The name of the project

required
repository_name str

The name of the repository

required
reference str

The reference of the artifact, can be digest or tag

required
page int

The page of results to return

1
page_size int

The number of results to return per page

10
with_tag bool

Whether to include the tags of the artifact in the response

True
with_label bool

Whether to include the labels of the artifact in the response

False
with_scan_overview bool

Whether to include the scan overview of the artifact in the response

False
with_signature bool

Whether the signature is included inside the tags of the returning artifact. Only works when setting with_tag==True.

False
with_immutable_status bool

Whether the immutable status is included inside the tags of the returning artifact.

False
with_accessory bool

Whether the accessories are included of the returning artifact.

False
mime_type str

A comma-separated lists of MIME types for the scan report or scan summary. The first mime type will be used when the report found for it. Currently the mime type supports:

* application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0
* application/vnd.security.vulnerability.report; version=1.1
'application/vnd.security.vulnerability.report; version=1.1'

Returns:

Type Description
Artifact

An artifact.

copy_artifact(project_name, repository_name, source) async

Copy an artifact.

Parameters:

Name Type Description Default
project_name str

Name of new artifact's project

required
repository_name str

Name of new artifact's repository

required
source str

The source artifact to copy from in the form of "project/repository:tag" or "project/repository@digest"

required

Returns:

Type Description
str

The location of the new artifact

delete_artifact(project_name, repository_name, reference, missing_ok=None) async

Delete an artifact.

Parameters:

Name Type Description Default
project_name str

The name of the project

required
repository_name str

The name of the repository

required
reference str

The reference of the artifact, can be digest or tag

required
missing_ok Optional[bool]

DEPRECATED: Whether to ignore 404 error when deleting the artifact

None

get_artifact_vulnerability_reports(project_name, repository_name, reference, mime_type=DEFAULT_MIME_TYPES) async

Get the vulnerability report(s) for an artifact.

Parameters:

Name Type Description Default
project_name str

The name of the project

required
repository_name str

The name of the repository

required
reference str

The reference of the artifact, can be digest or tag

required
mime_type Union[str, Sequence[str]]

MIME type or list of MIME types for the scan report or scan summary.

DEFAULT_MIME_TYPES

Returns:

Type Description
FirstDict[str, HarborVulnerabilityReport]

A dict of vulnerability reports keyed by MIME type. Supports the first() method to get the first report.

get_artifact_build_history(project_name, repository_name, reference, limit=None) async

Get the build history for an artifact.

Parameters:

Name Type Description Default
project_name str

The name of the project

required
repository_name str

The name of the repository

required
reference str

The reference of the artifact, can be digest or tag

required
limit Optional[int]

The maximum number of build history entries to return

None

Returns:

Type Description
List[BuildHistoryEntry]

The build history for the artifact

get_artifact_accessories(project_name, repository_name, reference, query=None, sort=None, page=1, page_size=10, limit=None, **kwargs) async

Get the tags for an artifact.

Parameters:

Name Type Description Default
project_name str

The name of the project

required
repository_name str

The name of the repository

required
reference str

The reference of the artifact, can be digest or tag

required
query Optional[str]

A query string to filter the accessories

Supported query patterns are:

* exact match(`"k=v"`)
* fuzzy match(`"k=~v"`)
* range(`"k=[min~max]"`)
* list with union releationship(`"k={v1 v2 v3}"`)
* list with intersection relationship(`"k=(v1 v2 v3)"`).

The value of range and list can be:

* string(enclosed by `"` or `'`)
* integer
* time(in format `"2020-04-09 02:36:00"`)

All of these query patterns should be put in the query string and separated by ",". e.g. "k1=v1,k2=~v2,k3=[min~max]"

None
sort Optional[str]

The sort order of the tags.

None
page int

The page of results to return

1
page_size int

The number of results to return per page

10
limit Optional[int]

The maximum number of results to return.

None

Returns:

Type Description
List[Accessory]

A list of Accessory objects for the artifact.

get_artifact_tags(project_name, repository_name, reference, query=None, sort=None, page=1, page_size=10, limit=None, with_signature=False, with_immutable_status=False, **kwargs) async

Get the tags for an artifact.

Parameters:

Name Type Description Default
project_name str

The name of the project

required
repository_name str

The name of the repository

required
reference str

The reference of the artifact, can be digest or tag

required
query Optional[str]

A query string to filter the tags

Supported query patterns are:

* exact match(`"k=v"`)
* fuzzy match(`"k=~v"`)
* range(`"k=[min~max]"`)
* list with union releationship(`"k={v1 v2 v3}"`)
* list with intersection relationship(`"k=(v1 v2 v3)"`).

The value of range and list can be:

* string(enclosed by `"` or `'`)
* integer
* time(in format `"2020-04-09 02:36:00"`)

All of these query patterns should be put in the query string and separated by ",". e.g. "k1=v1,k2=~v2,k3=[min~max]"

None
sort Optional[str]

The sort order of the tags. TODO: document this parameter

None
page int

The page of results to return

1
page_size int

The number of results to return per page

10
limit Optional[int]

The maximum number of results to return.

None
with_signature bool

Whether to include the signature of the tag in the response

False
with_immutable_status bool

Whether to include the immutable status of the tag in the response

False

Returns:

Type Description
List[Tag]

A list of Tag objects for the artifact.

create_artifact_tag(project_name, repository_name, reference, tag) async

Create a tag for an artifact.

Parameters:

Name Type Description Default
project_name str

The name of the project

required
repository_name str

The name of the repository

required
reference str

The reference of the artifact, can be digest or tag

required
tag Tag

The tag to create

required

Returns:

Type Description
str

The location of the created tag

delete_artifact_tag(project_name, repository_name, reference, tag_name, missing_ok=None) async

Delete a tag for an artifact.

Parameters:

Name Type Description Default
project_name str

The name of the project

required
repository_name str

The name of the repository

required
reference str

The reference of the artifact, can be digest or tag

required
tag_name str

The name of the tag to delete

required

add_artifact_label(project_name, repository_name, reference, label) async

Add a label to an artifact.

Parameters:

Name Type Description Default
project_name str

The name of the project

required
repository_name str

The name of the repository

required
reference str

The reference of the artifact, can be digest or tag

required
label Label

The label to add

required

delete_artifact_label(project_name, repository_name, reference, label_id, missing_ok=None) async

Delete an artifact.

Parameters:

Name Type Description Default
project_name str

The name of the project

required
repository_name str

The name of the repository

required
reference str

The reference of the artifact, can be digest or tag

required
label_id int

The id of the label to delete

required
missing_ok Optional[bool]

DEPRECATED: Whether to ignore 404 error when deleting the label

None

get_artifacts(project_name, repository_name, query=None, sort=None, page=1, page_size=10, limit=None, with_tag=True, with_label=False, with_scan_overview=False, with_signature=False, with_immutable_status=False, with_accessory=False, mime_type='application/vnd.security.vulnerability.report; version=1.1', **kwargs) async

Get the artifacts in a repository.

Parameters:

Name Type Description Default
project_name str

The name of the project

required
repository_name str

The name of the repository

required
query Optional[str]

A query string to filter the artifacts

Except the basic properties, the other supported queries includes:

* `"tags=*"` to list only tagged artifacts
* `"tags=nil"` to list only untagged artifacts
* `"tags=~v"` to list artifacts whose tag fuzzy matches "v"
* `"tags=v"` to list artifact whose tag exactly matches "v"
* `"labels=(id1, id2)"` to list artifacts that both labels with id1 and id2 are added to

The value of range and list can be:

* string(enclosed by `"` or `'`)
* integer
* time(in format `"2020-04-09 02:36:00"`)

All of these query patterns should be put in the query string and separated by ",". e.g. "k1=v1,k2=~v2,k3=[min~max]"

None
sort Optional[str]

The sort order of the artifacts.

None
page int

The page of results to return

1
page_size int

The number of results to return per page

10
limit Optional[int]

The maximum number of results to return.

None
with_tag bool

Whether to include the tags of the artifact in the response

True
with_label bool

Whether to include the labels of the artifact in the response

False
with_scan_overview bool

Whether to include the scan overview of the artifact in the response

False
with_signature bool

Whether the signature is included inside the tags of the returning artifacts. Only works when setting with_tag==True.

False
with_immutable_status bool

Whether the immutable status is included inside the tags of the returning artifacts.

False
with_accessory bool

Whether the accessories are included of the returning artifacts.

False
mime_type str

A comma-separated lists of MIME types for the scan report or scan summary. The first mime type will be used when the report found for it. Currently the mime type supports:

* application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0
* application/vnd.security.vulnerability.report; version=1.1
'application/vnd.security.vulnerability.report; version=1.1'

Returns:

Type Description
List[Artifact]

A list of artifacts in the repository matching the query.

get_artifact_vulnerabilities(project_name, repository_name, reference, mime_type='application/vnd.security.vulnerability.report; version=1.1') async

Get the vulnerabilities for an artifact.

Warning

This method is deprecated. Use get_artifact_vulnerability_reports instead.

Parameters:

Name Type Description Default
project_name str

The name of the project

required
repository_name str

The name of the repository

required
reference str

The reference of the artifact, can be digest or tag

required
mime_type str

A comma-separated lists of MIME types for the scan report or scan summary.

'application/vnd.security.vulnerability.report; version=1.1'

Returns:

Type Description
HarborVulnerabilityReport

The vulnerabilities for the artifact, or None if the artifact is not found