harbor_client.ScanApi

All URIs are relative to http://localhost/api/v2.0

MethodHTTP requestDescription
get_report_logGET /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/{report_id}/logGet the log of the scan report
scan_artifactPOST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scanScan the artifact
stop_scan_artifactPOST /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/stopCancelling a scan job for a particular artifact

get_report_log

Signature

get_report_log(project_name: str, repository_name: str, reference: str, report_id: str, x_request_id: Optional[str])-> str

Get the log of the scan report

Get the log of the scan report

Example

from __future__ import print_function
import time
import harbor_client
from harbor_client.rest import ApiException
from pprint import pprint

# Configure HTTP basic authorization: basic
configuration = harbor_client.Configuration()
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

# create an instance of the API class
api_instance = harbor_client.ScanApi(harbor_client.ApiClient(configuration))
project_name = 'project_name_example' # str | The name of the project
repository_name = 'repository_name_example' # str | The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb
reference = 'reference_example' # str | The reference of the artifact, can be digest or tag
report_id = 'report_id_example' # str | The report id to get the log
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Get the log of the scan report
    api_response = api_instance.get_report_log(project_name, repository_name, reference, report_id, x_request_id=x_request_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling ScanApi->get_report_log: %s\n" % e)

Parameters

NameTypeDescriptionNotes
project_namestrThe name of the project
repository_namestrThe name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb
referencestrThe reference of the artifact, can be digest or tag
report_idstrThe report id to get the log
x_request_idstrAn unique ID for the request[optional]

Return type

str

Authorization

basic

HTTP request headers

  • Content-Type: application/json
  • Accept: text/plain

[Back to top]

scan_artifact

Signature

scan_artifact(project_name: str, repository_name: str, reference: str, x_request_id: Optional[str])-> None

Scan the artifact

Scan the specified artifact

Example

from __future__ import print_function
import time
import harbor_client
from harbor_client.rest import ApiException
from pprint import pprint

# Configure HTTP basic authorization: basic
configuration = harbor_client.Configuration()
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

# create an instance of the API class
api_instance = harbor_client.ScanApi(harbor_client.ApiClient(configuration))
project_name = 'project_name_example' # str | The name of the project
repository_name = 'repository_name_example' # str | The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb
reference = 'reference_example' # str | The reference of the artifact, can be digest or tag
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Scan the artifact
    api_instance.scan_artifact(project_name, repository_name, reference, x_request_id=x_request_id)
except ApiException as e:
    print("Exception when calling ScanApi->scan_artifact: %s\n" % e)

Parameters

NameTypeDescriptionNotes
project_namestrThe name of the project
repository_namestrThe name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb
referencestrThe reference of the artifact, can be digest or tag
x_request_idstrAn unique ID for the request[optional]

Return type

void (empty response body)

Authorization

basic

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top]

stop_scan_artifact

Signature

stop_scan_artifact(project_name: str, repository_name: str, reference: str, x_request_id: Optional[str])-> None

Cancelling a scan job for a particular artifact

Cancelling a scan job for a particular artifact

Example

from __future__ import print_function
import time
import harbor_client
from harbor_client.rest import ApiException
from pprint import pprint

# Configure HTTP basic authorization: basic
configuration = harbor_client.Configuration()
configuration.username = 'YOUR_USERNAME'
configuration.password = 'YOUR_PASSWORD'

# create an instance of the API class
api_instance = harbor_client.ScanApi(harbor_client.ApiClient(configuration))
project_name = 'project_name_example' # str | The name of the project
repository_name = 'repository_name_example' # str | The name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb
reference = 'reference_example' # str | The reference of the artifact, can be digest or tag
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Cancelling a scan job for a particular artifact
    api_instance.stop_scan_artifact(project_name, repository_name, reference, x_request_id=x_request_id)
except ApiException as e:
    print("Exception when calling ScanApi->stop_scan_artifact: %s\n" % e)

Parameters

NameTypeDescriptionNotes
project_namestrThe name of the project
repository_namestrThe name of the repository. If it contains slash, encode it with URL encoding. e.g. a/b -> a%252Fb
referencestrThe reference of the artifact, can be digest or tag
x_request_idstrAn unique ID for the request[optional]

Return type

void (empty response body)

Authorization

basic

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top]