harbor_client.ScannerApi

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

MethodHTTP requestDescription
create_scannerPOST /scannersCreate a scanner registration
delete_scannerDELETE /scanners/{registration_id}Delete a scanner registration
get_scannerGET /scanners/{registration_id}Get a scanner registration details
get_scanner_metadataGET /scanners/{registration_id}/metadataGet the metadata of the specified scanner registration
list_scannersGET /scannersList scanner registrations
ping_scannerPOST /scanners/pingTests scanner registration settings
set_scanner_as_defaultPATCH /scanners/{registration_id}Set system default scanner registration
update_scannerPUT /scanners/{registration_id}Update a scanner registration

create_scanner

Signature

create_scanner(registration: ScannerRegistrationReq, x_request_id: Optional[str])-> None

Create a scanner registration

Creats a new scanner registration with the given data.

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.ScannerApi(harbor_client.ApiClient(configuration))
registration = harbor_client.ScannerRegistrationReq() # ScannerRegistrationReq | A scanner registration to be created.
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Create a scanner registration
    api_instance.create_scanner(registration, x_request_id=x_request_id)
except ApiException as e:
    print("Exception when calling ScannerApi->create_scanner: %s\n" % e)

Parameters

NameTypeDescriptionNotes
registrationScannerRegistrationReqA scanner registration to be created.
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]

delete_scanner

Signature

delete_scanner(registration_id: str, x_request_id: Optional[str])-> ScannerRegistration

Delete a scanner registration

Deletes the specified scanner registration.

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.ScannerApi(harbor_client.ApiClient(configuration))
registration_id = 'registration_id_example' # str | The scanner registration identifier.
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Delete a scanner registration
    api_response = api_instance.delete_scanner(registration_id, x_request_id=x_request_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling ScannerApi->delete_scanner: %s\n" % e)

Parameters

NameTypeDescriptionNotes
registration_idstrThe scanner registration identifier.
x_request_idstrAn unique ID for the request[optional]

Return type

ScannerRegistration

Authorization

basic

HTTP request headers

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

[Back to top]

get_scanner

Signature

get_scanner(registration_id: str, x_request_id: Optional[str])-> ScannerRegistration

Get a scanner registration details

Retruns the details of the specified scanner registration.

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.ScannerApi(harbor_client.ApiClient(configuration))
registration_id = 'registration_id_example' # str | The scanner registration identifer.
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Get a scanner registration details
    api_response = api_instance.get_scanner(registration_id, x_request_id=x_request_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling ScannerApi->get_scanner: %s\n" % e)

Parameters

NameTypeDescriptionNotes
registration_idstrThe scanner registration identifer.
x_request_idstrAn unique ID for the request[optional]

Return type

ScannerRegistration

Authorization

basic

HTTP request headers

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

[Back to top]

get_scanner_metadata

Signature

get_scanner_metadata(registration_id: str, x_request_id: Optional[str])-> ScannerAdapterMetadata

Get the metadata of the specified scanner registration

Get the metadata of the specified scanner registration, including the capabilities and customized properties.

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.ScannerApi(harbor_client.ApiClient(configuration))
registration_id = 'registration_id_example' # str | The scanner registration identifier.
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Get the metadata of the specified scanner registration
    api_response = api_instance.get_scanner_metadata(registration_id, x_request_id=x_request_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling ScannerApi->get_scanner_metadata: %s\n" % e)

Parameters

NameTypeDescriptionNotes
registration_idstrThe scanner registration identifier.
x_request_idstrAn unique ID for the request[optional]

Return type

ScannerAdapterMetadata

Authorization

basic

HTTP request headers

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

[Back to top]

list_scanners

Signature

list_scanners(x_request_id: Optional[str], q: Optional[str], sort: Optional[str], page: Optional[int], page_size: Optional[int])-> list[ScannerRegistration]

List scanner registrations

Returns a list of currently configured scanner registrations.

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.ScannerApi(harbor_client.ApiClient(configuration))
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)
q = 'q_example' # str | Query string to query resources. Supported query patterns are \"exact match(k=v)\", \"fuzzy match(k=~v)\", \"range(k=[min~max])\", \"list with union releationship(k={v1 v2 v3})\" and \"list with intersetion relationship(k=(v1 v2 v3))\". The value of range and list can be string(enclosed by \" or '), integer or time(in format \"2020-04-09 02:36:00\"). All of these query patterns should be put in the query string \"q=xxx\" and splitted by \",\". e.g. q=k1=v1,k2=~v2,k3=[min~max] (optional)
sort = 'sort_example' # str | Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with \"sort=field1,-field2\" (optional)
page = 1 # int | The page number (optional) (default to 1)
page_size = 10 # int | The size of per page (optional) (default to 10)

try:
    # List scanner registrations
    api_response = api_instance.list_scanners(x_request_id=x_request_id, q=q, sort=sort, page=page, page_size=page_size)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling ScannerApi->list_scanners: %s\n" % e)

Parameters

NameTypeDescriptionNotes
x_request_idstrAn unique ID for the request[optional]
qstrQuery string to query resources. Supported query patterns are "exact match(k=v)", "fuzzy match(k=~v)", "range(k=[min~max])", "list with union releationship(k={v1 v2 v3})" and "list with intersetion relationship(k=(v1 v2 v3))". The value of range and list can be string(enclosed by " or '), integer or time(in format "2020-04-09 02:36:00"). All of these query patterns should be put in the query string "q=xxx" and splitted by ",". e.g. q=k1=v1,k2=~v2,k3=[min~max][optional]
sortstrSort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with "sort=field1,-field2"[optional]
pageintThe page number[optional] [default to 1]
page_sizeintThe size of per page[optional] [default to 10]

Return type

list[ScannerRegistration]

Authorization

basic

HTTP request headers

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

[Back to top]

ping_scanner

Signature

ping_scanner(settings: ScannerRegistrationSettings, x_request_id: Optional[str])-> None

Tests scanner registration settings

Pings scanner adapter to test endpoint URL and authorization settings.

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.ScannerApi(harbor_client.ApiClient(configuration))
settings = harbor_client.ScannerRegistrationSettings() # ScannerRegistrationSettings | A scanner registration settings to be tested.
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Tests scanner registration settings
    api_instance.ping_scanner(settings, x_request_id=x_request_id)
except ApiException as e:
    print("Exception when calling ScannerApi->ping_scanner: %s\n" % e)

Parameters

NameTypeDescriptionNotes
settingsScannerRegistrationSettingsA scanner registration settings to be tested.
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]

set_scanner_as_default

Signature

set_scanner_as_default(registration_id: str, payload: IsDefault, x_request_id: Optional[str])-> None

Set system default scanner registration

Set the specified scanner registration as the system default one.

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.ScannerApi(harbor_client.ApiClient(configuration))
registration_id = 'registration_id_example' # str | The scanner registration identifier.
payload = harbor_client.IsDefault() # IsDefault | 
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Set system default scanner registration
    api_instance.set_scanner_as_default(registration_id, payload, x_request_id=x_request_id)
except ApiException as e:
    print("Exception when calling ScannerApi->set_scanner_as_default: %s\n" % e)

Parameters

NameTypeDescriptionNotes
registration_idstrThe scanner registration identifier.
payloadIsDefault
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]

update_scanner

Signature

update_scanner(registration_id: str, registration: ScannerRegistrationReq, x_request_id: Optional[str])-> None

Update a scanner registration

Updates the specified scanner registration.

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.ScannerApi(harbor_client.ApiClient(configuration))
registration_id = 'registration_id_example' # str | The scanner registration identifier.
registration = harbor_client.ScannerRegistrationReq() # ScannerRegistrationReq | A scanner registraiton to be updated.
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Update a scanner registration
    api_instance.update_scanner(registration_id, registration, x_request_id=x_request_id)
except ApiException as e:
    print("Exception when calling ScannerApi->update_scanner: %s\n" % e)

Parameters

NameTypeDescriptionNotes
registration_idstrThe scanner registration identifier.
registrationScannerRegistrationReqA scanner registraiton to be updated.
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]