mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-02 15:14:09 +01:00
c283a02e5f
Signed-off-by: danfengliu <danfengl@vmware.com>
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
import base
|
|
import v2_swagger_client
|
|
from v2_swagger_client.rest import ApiException
|
|
|
|
class Artifact(base.Base):
|
|
def get_reference_info(self, project_name, repo_name, reference, **kwargs):
|
|
client = self._get_client(**kwargs)
|
|
params = {}
|
|
if "with_signature" in kwargs:
|
|
params["with_signature"] = kwargs["with_signature"]
|
|
return client.get_artifact_with_http_info(project_name, repo_name, reference, **params )
|
|
|
|
def add_label_to_reference(self, project_name, repo_name, reference, label_id, **kwargs):
|
|
client = self._get_client(**kwargs)
|
|
label = v2_swagger_client.Label(id = label_id)
|
|
return client.add_label_with_http_info(project_name, repo_name, reference, label)
|
|
|
|
def copy_artifact(self, project_name, repo_name, _from, expect_status_code = 201, expect_response_body = None, **kwargs):
|
|
client = self._get_client(**kwargs)
|
|
|
|
try:
|
|
data, status_code, _ = client.copy_artifact_with_http_info(project_name, repo_name, _from)
|
|
except ApiException as e:
|
|
base._assert_status_code(expect_status_code, e.status)
|
|
if expect_response_body is not None:
|
|
base._assert_status_body(expect_response_body, e.body)
|
|
return
|
|
|
|
base._assert_status_code(expect_status_code, status_code)
|
|
base._assert_status_code(201, status_code)
|
|
return data
|