Adding an Image Retention Policy
Function
Add an image retention policy.
URI
POST /v2/manage/namespaces/{namespace}/repos/{repository}/retentions
Table 1 describes the parameters.
Request
Request parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| algorithm | Yes | String | Retention policy matching rule. The value is or. |
| rules | Yes | Array of object | For details, see Table 3. |
| 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 date_rule or tag_rule. |
| 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. |
{
"algorithm": "or",
"rules": [
{
"params": {
"days": "30"
},
"tag_selectors": [
{
"kind": "label",
"pattern": "v5"
},
{
"kind": "label",
"pattern": "1.0.1"
},
{
"kind": "regexp",
"pattern": "^123$"
}
],
"template": "date_rule"
}
]
} Response
Response parameters
| Parameter | Type | Description |
|---|---|---|
| id | Interger | ID |
Response example
{"id": 34} Status Code
Table 6 describes the status codes of this API.
Last Article: Updating Trigger Settings
Next Article: Obtaining the List of Image Retention Policies
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.