Update an Archive Policy

JFrog REST APIs

Products
JFrog Xray
Content Type
REST API
ft:sourceType
Paligo

Description: Updates an existing archive policy based on the policy key.

Note

This Cold Storage feature is available only for Artifactory Enterprise and Enterprise+ users.

Since: Artifactory 7.27.3

Security: Requires an admin user

Usage: PUT /api/retention/archive/policies/{key}

Produces: application/json

Consumes: application/json

Request Parameters:

Parameters

Type

Description

Required/Optional

key

string

Unique policy key that identifies the policy.

Required

enabled

boolean

Enable/disable policy. If disabled, policy execution is blocked.

Required

cronExp

string

The Cron expression for scheduling the policy.

Required

aqlQuery

string

Search for artifacts to be archived using Artifactory Query Language (AQL). This can be used instead of searchCriteriaForm to include/exclude artifacts in the retention policy.

The AQL query can be based on these properties:

  • Include or exclude repository and an inner path (one or many)

  • Include or exclude associated properties (one or many)

  • Include an age

  • Last downloaded before configurable X (weeks, months, years)

  • Deployed before configurable X (weeks, months, years)

Required if searchCriteriaForm is not provided

searchCriteriaForm

string

Search Criteria Form for retention policy. This can be used instead of aqlQuery to include/exclude artifacts in the retention policy.

Required if aqlQuery is not provided

description

string

Description for the policy.

Optional

durationInMinutes

long

The maximum duration (in minutes) for policy execution. If policy execution exceeds this period, it is stopped.

Default value is 0.

Optional

expirationTimeInMonths

long

The expiration period (in months) that it takes for archived artifacts to be cleaned up from the Cold instance.

Default value is 0.

Optional

skipTrashcan

boolean

Prevent the transfer of the artifacts to the trash can repository, and allow the artifacts to be deleted by a full GC cleanup.Browsing ArtifactsManaging Disk Space Usage

Default value is false.

Optional

Search Criteria Form

Field

Type

Description

properties

string

Include/Exclude all properties with the specified "propertyKey" and a single "propertyValue".

Supports and/or operator.

Example

    "properties": {
      "include": {
        "operator": "or",
        "values": [
          {
            "propertyKey": "example-prop-key-1",
            "propertyValue": "prop-val-1"
          },
          {
            "propertyKey": "example-prop-key-1",
            "propertyValue": "prop-val-2"
          }
        ]
      },
      "exclude": {
        "operator": "or",
        "values": [
          {
            "propertyKey": "example-prop-key-2",
            "propertyValue": "prop-val-1"
          }
        ]
      }
    }

repositories

string

Include/Exclude all repository keys.

Supports and/or operator.

ExampleExample

    "repositories": {
      "include": {
        "operator": "or",
        "values": [
          "repo-1",
          "repo-2"
        ]
      },
      "exclude": {
        "operator": "and",
        "values": [
          "repo-*",
          "*-3"
        ]
      }
    }

path

string

Include/Exclude all items with specified paths

Supports and/or operator.

ExampleExample

    "paths": {
      "include": {
        "operator": "or",
        "values": [
          "path-1",
          "path-2"
        ]
      },
      "exclude": {
        "operator": "or",
        "values": [
          "path-3"
        ]
      }
    }

name

string

Include/Exclude all items with the specified names.

Supports and/or operator.

ExampleExample

    "names": {
      "include": {
        "operator": "or",
        "values": [
          "name-1",
          "name-2"
        ]
      },
      "exclude": {
        "operator": "or",
        "values": [
          "name-3"
        ]
      }
    }

createdBefore

long

Include all items that were created before the relative time provided (such as, 2 years ago, 3 months ago)

downloadedBefore

long

Include all items that were last downloaded before the relative time provided (such as, 2 years ago, 3 months ago)

Sample Request: Using aqlQuery parameter

PUT /api/retention/archive/policies/example-policy-key

{
   "key": "example-policy-key",
   "enabled": true,
   "description": "policy description",
   "aqlQuery": "items.find({\"type\":{\"$eq\":\"file\"}})",
   "cronExp": "0 15 10 L * ?",
   "durationInMinutes": 0,
   "expirationTimeInMonths": 0,
   "skipTrashcan": true
}

Sample Response: For aqlQuery parameter

{
   "key": "example-policy-key",
   "enabled": true,
   "description": "policy description",
   "aqlQuery": "items.find({\"type\":{\"$eq\":\"file\"}})",
   "cronExp": "0 15 10 L * ?",
   "durationInMinutes": 0,
   "expirationTimeInMonths": 0,
   "skipTrashcan": true
}

Sample Request: Using searchCriteriaForm parameter

{
  "key": "myPolicy",
  "description": "Demo policy - archive using search criteria form",
  "enabled": false,
  "searchCriteriaForm": {
    "properties": {
      "include": {
        "values": [{
            "propertyKey":"updated",
            "propertyValue":"updated"
        }]
      },
      "exclude": {
        "values": [
        ]
      }
    },
    "repositories": {
      "include": {
        "values": [
          "include-*",
          "*-repo"
        ]
      },
      "exclude": {
        "values": []
      }
    },
    "paths": {
      "include": {
        "values": []
      },
      "exclude": {
        "values": [
          "exclude-*",
          "*-path"
        ]
      }
    },
    "createdBefore":2,
    "downloadedBefore":3
}
}

Sample Response: : Using searchCriteriaForm parameter

{
    "key": "myPolicy",
    "enabled": false,
    "description": "Demo policy - archive using search criteria form",
    "durationInMinutes": 0,
    "expirationTimeInMonths": 0,
    "skipTrashcan": false,
    "searchCriteriaForm": {
        "properties": {
            "include": {
                "operator": "or",
                "values": [
                    {
                        "propertyKey": "updated",
                        "propertyValue": "updated"
                    }
                ]
            },
            "exclude": {
                "operator": "or",
                "values": []
            }
        },
        "repositories": {
            "include": {
                "operator": "or",
                "values": [
                    "include-*",
                    "*-repo"
                ]
            },
            "exclude": {
                "operator": "or",
                "values": []
            }
        },
        "paths": {
            "include": {
                "operator": "or",
                "values": []
            },
            "exclude": {
                "operator": "or",
                "values": [
                    "exclude-*",
                    "*-path"
                ]
            }
        },
        "createdBefore": 2,
        "downloadedBefore": 3
    }
}

Status:

201: Success