Help Center> SoftWare Repository for Container> API Reference> API> Modifying an Image Retention Policy

Modifying an Image Retention Policy

Function

Modify an image retention policy.

URI

PATCH /v2/manage/namespaces/{namespace}/repos/{repository}/retentions/{retention_id}

Table 1 describes the parameters.

Table 1 Parameter description

Parameter

Mandatory

Type

Description

namespace

Yes

String

Organization name

repository

Yes

String

Image repository name

retention_id

Yes

String

Image retention policy ID

Request

Request parameters

Table 2 Request body parameter description

Parameter

Mandatory

Type

Description

rules

Yes

Array of object

For details, see Table 3.

Table 3 rules parameter description

Parameter

Mandatory

Type

Description

params

Yes

Object

If template is set to date_rule, set params["days"].

If template is set to tag_rule, set params["num"].

tag_selectors

Yes

Array of object

Image tags that are not counted in the retention policy. For details, see Table 4.

template

Yes

String

Retention policy type. The value can be set date_rule and tag_rule.

Table 4 tag_selectors parameter description

Parameter

Mandatory

Type

Description

kind

Yes

String

Matching rule. The value can be label or regexp.

pattern

Yes

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.

Request example
{
    "rules": [
        {
            "params": {
                "days": "30"
            },
            "tag_selectors": [
                {
                    "kind": "label",
                    "pattern": "v5"
                },
                {
                    "kind": "label",
                    "pattern": "1.0.1"
                },
                {
                    "kind": "regexp",
                    "pattern": "^123$"
                }
            ],
            "template": "date_rule"
        }
    ]
}

Response

{}

Status Code

Table 5 describes the status codes of this API.

Table 5 Status code

Status Code

Description

201

Operation succeeded.

400

Request error.

401

Authentication failed.

404

The organization does not exist.

500

Failed to complete the request because of an internal service error.