harbor_client.RetentionApi

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

MethodHTTP requestDescription
create_retentionPOST /retentionsCreate Retention Policy
delete_retentionDELETE /retentions/{id}Delete Retention Policy
get_rentenition_metadataGET /retentions/metadatasGet Retention Metadatas
get_retentionGET /retentions/{id}Get Retention Policy
get_retention_task_logGET /retentions/{id}/executions/{eid}/tasks/{tid}Get Retention job task log
list_retention_executionsGET /retentions/{id}/executionsGet Retention executions
list_retention_tasksGET /retentions/{id}/executions/{eid}/tasksGet Retention tasks
operate_retention_executionPATCH /retentions/{id}/executions/{eid}Stop a Retention execution
trigger_retention_executionPOST /retentions/{id}/executionsTrigger a Retention Execution
update_retentionPUT /retentions/{id}Update Retention Policy

create_retention

Signature

create_retention(policy: RetentionPolicy, x_request_id: Optional[str])-> None

Create Retention Policy

Create Retention Policy, you can reference metadatas API for the policy model. You can check project metadatas to find whether a retention policy is already binded. This method should only be called when no retention policy binded to project yet.

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.RetentionApi(harbor_client.ApiClient(configuration))
policy = harbor_client.RetentionPolicy() # RetentionPolicy | Create Retention Policy successfully.
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Create Retention Policy
    api_instance.create_retention(policy, x_request_id=x_request_id)
except ApiException as e:
    print("Exception when calling RetentionApi->create_retention: %s\n" % e)

Parameters

NameTypeDescriptionNotes
policyRetentionPolicyCreate Retention Policy successfully.
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_retention

Signature

delete_retention(id: int, x_request_id: Optional[str])-> None

Delete Retention Policy

Delete Retention Policy, you can reference metadatas API for the policy model. You can check project metadatas to find whether a retention policy is already binded. This method should only be called when retention policy has already binded to project.

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

try:
    # Delete Retention Policy
    api_instance.delete_retention(id, x_request_id=x_request_id)
except ApiException as e:
    print("Exception when calling RetentionApi->delete_retention: %s\n" % e)

Parameters

NameTypeDescriptionNotes
idintRetention 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_rentenition_metadata

Signature

get_rentenition_metadata(x_request_id: Optional[str])-> RetentionMetadata

Get Retention Metadatas

Get Retention Metadatas.

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

try:
    # Get Retention Metadatas
    api_response = api_instance.get_rentenition_metadata(x_request_id=x_request_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling RetentionApi->get_rentenition_metadata: %s\n" % e)

Parameters

NameTypeDescriptionNotes
x_request_idstrAn unique ID for the request[optional]

Return type

RetentionMetadata

Authorization

basic

HTTP request headers

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

[Back to top]

get_retention

Signature

get_retention(id: int, x_request_id: Optional[str])-> RetentionPolicy

Get Retention Policy

Get Retention Policy.

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

try:
    # Get Retention Policy
    api_response = api_instance.get_retention(id, x_request_id=x_request_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling RetentionApi->get_retention: %s\n" % e)

Parameters

NameTypeDescriptionNotes
idintRetention ID.
x_request_idstrAn unique ID for the request[optional]

Return type

RetentionPolicy

Authorization

basic

HTTP request headers

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

[Back to top]

get_retention_task_log

Signature

get_retention_task_log(id: int, eid: int, tid: int, x_request_id: Optional[str])-> str

Get Retention job task log

Get Retention job task log, tags ratain or deletion detail will be shown in a table.

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.RetentionApi(harbor_client.ApiClient(configuration))
id = 789 # int | Retention ID.
eid = 789 # int | Retention execution ID.
tid = 789 # int | Retention execution ID.
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Get Retention job task log
    api_response = api_instance.get_retention_task_log(id, eid, tid, x_request_id=x_request_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling RetentionApi->get_retention_task_log: %s\n" % e)

Parameters

NameTypeDescriptionNotes
idintRetention ID.
eidintRetention execution ID.
tidintRetention execution ID.
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]

list_retention_executions

Signature

list_retention_executions(id: int, x_request_id: Optional[str], page: Optional[int], page_size: Optional[int])-> list[RetentionExecution]

Get Retention executions

Get Retention executions, execution status may be delayed before job service schedule it up.

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.RetentionApi(harbor_client.ApiClient(configuration))
id = 789 # int | Retention ID.
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)
page = 789 # int | The page number. (optional)
page_size = 789 # int | The size of per page. (optional)

try:
    # Get Retention executions
    api_response = api_instance.list_retention_executions(id, x_request_id=x_request_id, page=page, page_size=page_size)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling RetentionApi->list_retention_executions: %s\n" % e)

Parameters

NameTypeDescriptionNotes
idintRetention ID.
x_request_idstrAn unique ID for the request[optional]
pageintThe page number.[optional]
page_sizeintThe size of per page.[optional]

Return type

list[RetentionExecution]

Authorization

basic

HTTP request headers

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

[Back to top]

list_retention_tasks

Signature

list_retention_tasks(id: int, eid: int, x_request_id: Optional[str], page: Optional[int], page_size: Optional[int])-> list[RetentionExecutionTask]

Get Retention tasks

Get Retention tasks, each repository as a task.

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.RetentionApi(harbor_client.ApiClient(configuration))
id = 789 # int | Retention ID.
eid = 789 # int | Retention execution ID.
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)
page = 789 # int | The page number. (optional)
page_size = 789 # int | The size of per page. (optional)

try:
    # Get Retention tasks
    api_response = api_instance.list_retention_tasks(id, eid, x_request_id=x_request_id, page=page, page_size=page_size)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling RetentionApi->list_retention_tasks: %s\n" % e)

Parameters

NameTypeDescriptionNotes
idintRetention ID.
eidintRetention execution ID.
x_request_idstrAn unique ID for the request[optional]
pageintThe page number.[optional]
page_sizeintThe size of per page.[optional]

Return type

list[RetentionExecutionTask]

Authorization

basic

HTTP request headers

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

[Back to top]

operate_retention_execution

Signature

operate_retention_execution(id: int, eid: int, body: Body1, x_request_id: Optional[str])-> None

Stop a Retention execution

Stop a Retention execution, only support "stop" action now.

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.RetentionApi(harbor_client.ApiClient(configuration))
id = 789 # int | Retention ID.
eid = 789 # int | Retention execution ID.
body = harbor_client.Body1() # Body1 | The action, only support \"stop\" now.
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Stop a Retention execution
    api_instance.operate_retention_execution(id, eid, body, x_request_id=x_request_id)
except ApiException as e:
    print("Exception when calling RetentionApi->operate_retention_execution: %s\n" % e)

Parameters

NameTypeDescriptionNotes
idintRetention ID.
eidintRetention execution ID.
bodyBody1The action, only support "stop" now.
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]

trigger_retention_execution

Signature

trigger_retention_execution(id: int, body: Body, x_request_id: Optional[str])-> None

Trigger a Retention Execution

Trigger a Retention Execution, if dry_run is True, nothing would be deleted actually.

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.RetentionApi(harbor_client.ApiClient(configuration))
id = 789 # int | Retention ID.
body = harbor_client.Body() # Body | 
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Trigger a Retention Execution
    api_instance.trigger_retention_execution(id, body, x_request_id=x_request_id)
except ApiException as e:
    print("Exception when calling RetentionApi->trigger_retention_execution: %s\n" % e)

Parameters

NameTypeDescriptionNotes
idintRetention ID.
bodyBody
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: text/plain

[Back to top]

update_retention

Signature

update_retention(id: int, policy: RetentionPolicy, x_request_id: Optional[str])-> None

Update Retention Policy

Update Retention Policy, you can reference metadatas API for the policy model. You can check project metadatas to find whether a retention policy is already binded. This method should only be called when retention policy has already binded to project.

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.RetentionApi(harbor_client.ApiClient(configuration))
id = 789 # int | Retention ID.
policy = harbor_client.RetentionPolicy() # RetentionPolicy | 
x_request_id = 'x_request_id_example' # str | An unique ID for the request (optional)

try:
    # Update Retention Policy
    api_instance.update_retention(id, policy, x_request_id=x_request_id)
except ApiException as e:
    print("Exception when calling RetentionApi->update_retention: %s\n" % e)

Parameters

NameTypeDescriptionNotes
idintRetention ID.
policyRetentionPolicy
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]