harbor_client.LabelApi

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

MethodHTTP requestDescription
create_labelPOST /labelsPost creates a label
delete_labelDELETE /labels/{label_id}Delete the label specified by ID.
get_label_by_idGET /labels/{label_id}Get the label specified by ID.
list_labelsGET /labelsList labels according to the query strings.
update_labelPUT /labels/{label_id}Update the label properties.

create_label

Signature

create_label(label: Label, x_request_id: Optional[str])-> None

Post creates a label

This endpoint let user creates a label.

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.LabelApi(harbor_client.ApiClient(configuration))
label = harbor_client.Label() # Label | The json object of label.
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Post creates a label
    api_instance.create_label(label, x_request_id=x_request_id)
except ApiException as e:
    print("Exception when calling LabelApi->create_label: %s\n" % e)

Parameters

NameTypeDescriptionNotes
labelLabelThe json object of label.
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_label

Signature

delete_label(label_id: int, x_request_id: Optional[str])-> None

Delete the label specified by ID.

Delete the label specified by ID.

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.LabelApi(harbor_client.ApiClient(configuration))
label_id = 789 # int | Label ID
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Delete the label specified by ID.
    api_instance.delete_label(label_id, x_request_id=x_request_id)
except ApiException as e:
    print("Exception when calling LabelApi->delete_label: %s\n" % e)

Parameters

NameTypeDescriptionNotes
label_idintLabel ID
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]

get_label_by_id

Signature

get_label_by_id(label_id: int, x_request_id: Optional[str])-> Label

Get the label specified by ID.

This endpoint let user get the label by specific ID.

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.LabelApi(harbor_client.ApiClient(configuration))
label_id = 789 # int | Label ID
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Get the label specified by ID.
    api_response = api_instance.get_label_by_id(label_id, x_request_id=x_request_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling LabelApi->get_label_by_id: %s\n" % e)

Parameters

NameTypeDescriptionNotes
label_idintLabel ID
x_request_idstrAn unique ID for the request[optional]

Return type

Label

Authorization

basic

HTTP request headers

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

[Back to top]

list_labels

Signature

list_labels(x_request_id: Optional[str], q: Optional[str], sort: Optional[str], page: Optional[int], page_size: Optional[int], name: Optional[str], scope: Optional[str], project_id: Optional[int])-> list[Label]

List labels according to the query strings.

This endpoint let user list labels by name, scope and project_id

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.LabelApi(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)
name = 'name_example' # str | The label name. (optional)
scope = 'scope_example' # str | The label scope. Valid values are g and p. g for global labels and p for project labels. (optional)
project_id = 789 # int | Relevant project ID, required when scope is p. (optional)

try:
    # List labels according to the query strings.
    api_response = api_instance.list_labels(x_request_id=x_request_id, q=q, sort=sort, page=page, page_size=page_size, name=name, scope=scope, project_id=project_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling LabelApi->list_labels: %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]
namestrThe label name.[optional]
scopestrThe label scope. Valid values are g and p. g for global labels and p for project labels.[optional]
project_idintRelevant project ID, required when scope is p.[optional]

Return type

list[Label]

Authorization

basic

HTTP request headers

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

[Back to top]

update_label

Signature

update_label(label_id: int, label: Label, x_request_id: Optional[str])-> None

Update the label properties.

This endpoint let user update label 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.LabelApi(harbor_client.ApiClient(configuration))
label_id = 789 # int | Label ID
label = harbor_client.Label() # Label | The updated label json object.
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Update the label properties.
    api_instance.update_label(label_id, label, x_request_id=x_request_id)
except ApiException as e:
    print("Exception when calling LabelApi->update_label: %s\n" % e)

Parameters

NameTypeDescriptionNotes
label_idintLabel ID
labelLabelThe updated label json object.
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]