Updated on 2023-04-04 GMT+08:00

Obtaining the List of Image Retention Policy

Function

Obtain the list of image retention policy.

URI

GET /v2/manage/namespaces/{namespace}/repos/{repository}/retentions

Table 1 describes the parameters.

Table 1 Parameter description

Parameter

Mandatory

Type

Description

namespace

Yes

String

Organization name.

repository

Yes

String

Image repository name.

Request

  • Request parameters

    N/A

  • Example request
    GET https://{Endpoint}/v2/manage/namespaces/group/repos/busybox/retentions

Response

  • Response parameters
    Table 2 Response body parameter description

    Parameter

    Type

    Description.

    [Array element]

    Array of objects

    Obtaining the list of image retention policy.

    Table 3 [Array element] parameters description

    Parameter

    Type

    Description

    algorithm

    String

    Retention policy matching rule. The value is or.

    id

    Integer

    Rule ID.

    rules

    Array of objects

    Image retention policy.

    scope

    String

    Reserved field.

    Table 4 rules parameter description

    Parameter

    Type

    Description

    template

    String

    Retention policy type. The value can be date_rule (number of days) or tag_rule (number of tags).

    params

    Object

    • If template is set to date_rule, set params to {"days": "xxx"}.
    • If template is set to tag_rule, set params to {"num": "xxx"}.

    tag_selectors

    Array of objects

    Image tags that are not counted in the retention policy.

    Table 5 tag_selectors parameter description

    Parameter

    Type

    Description

    kind

    String

    Matching rule. The value can be label or regexp.

    pattern

    String

    • If kind is set to label, set this parameter to specific image tags.
    • If kind is set to regexp, set this parameter to a regular expression.
  • Example response
    [
        {
            "algorithm": "or",
            "id": 1093,
            "rules": [
                {
                    "template": "date_rule",
                    "params": {
                        "days": "30"
                    },
                    "tag_selectors": [
                        {
                            "kind": "label",
                            "pattern": "v5"
                        },
                        {
                            "kind": "label",
                            "pattern": "1.0.1"
                        },
                        {
                            "kind": "regexp",
                            "pattern": "^123$"
                        }
                    ]
                }
            ],
            "scope": ""
        }
    ]

Status Code

Status Code

Description

200

Request successful.

400

Request error.

401

Authentication failed.

404

The organization does not exist.

500

Internal error.