Get All Smart Archiving Policies API

JFrog REST APIs

Content Type
REST API
ft:sourceType
Paligo

Description: This API is called to return a list of all the existing smart archiving policies for either a specific project or for the entire system.

Security: Requires a platform admin. A project admin with permission can call this API on the project level.

Usage: GET http://{host:port}/artifactory/api/archive/v2/packages/policies

Produces: application/json

Sample Query

GET http://{host:port}/artifactory/api/archive/v2/packages/policies?projectKey=<optionally supply projectKey>

Query Parameters:

Field

Type

Description

projectKey

string

This parameter is used when calling this API to return all archive policies for a specific project. This parameter identifies the project of the policies you want to receive.

This parameter is optional for a platform admin, but not using it will return all archive policies in Artifactory, both global policies and project-level policies.

This parameter is mandatory for a project admin.

Sample Response:

[
   {
       "key": "key1",
       "description": "some test description",
       "cronExp": "0 15 10 * * ? 2024",
       "durationInMinutes": 150,
       "enabled": false,
       "skipTrashcan": false,
       "searchCriteria": {
           "packageTypes": [
               "docker",
               "maven"
           ],
           "repos": [
               "repo1",
               "repo2"
           ],
           "excludedRepos": [],
           "includedPackages": [
               "com/jfrog",
           ],
           "excludedPackages": [
               "com/jfrog/latest",
           ],
           "includeAllProjects": false,
           "includedProjects": [
               "project1",
               "project2"
           ],
           "createdBeforeInMonths": 12,
           "lastDownloadedBeforeInMonths": 1,
           "keepLastNVersions": 0
       }
   },
   {
       "key": "key2",
       "description": "some test description 2",
       "durationInMinutes": 150,
       "enabled": false,
       "skipTrashcan": false,
       "searchCriteria": {
           "packageTypes": [
               "docker"
           ],
           "repos": [
               "repo1"
           ],
           "excludedRepos": [],
           "includedPackages": [
               "jfrog*"
           ],
           "excludedPackages": [],
           "includeAllProjects": false,
           "includedProjects": [
               "project1",
               "project2"
           ],
           "createdBeforeInMonths": 3,
           "lastDownloadedBeforeInMonths": 1,
           "keepLastNVersions": 0
       }
   }
]

The response includes the following information:

Property

Description

key

The ID that identifies the policy. This ID was configured for the policy when it was created.

description

Description that was defined for the policy.

cronExp

The cron expression determines when the policy is run.

durationInMinutes

The maximum duration (in minutes) for policy execution, after which the policy will stop running even if not completed. While setting a maximum run duration for a policy is useful for adhering to a strict archive schedule, it can cause the policy to stop before completion.

enabled

A true value means the policy can be executed. A false value means that it cannot.

skipTrashcan

A true value means that when this policy is executed, packages will be permanently deleted. false means that when the policy is executed packages will be deleted to the Trash Can.

searchCriteria

The criteria that define aspects of the policy such as package types (docker, maven), names of repositories in which the policy will run, and other relevant criteria. For more details see the table below.

Search Criteria

Field

Type

Description

packageTypes

string

The package types that are archived by the policy. For a list of the permitted package types, click here.Package Types Coverage

repos

string

Specify one or more patterns for the repository name(s) on which you want the archive policy to run. You can also specify explicit repository names. Specifying at least one pattern or explicit name is mandatory. Only packages in repositories that match the pattern or explicit name will be archived.

excludedRepos

string

Specifies patterns for repository names or explicit repository names that you want to be excluded from the archive policy. This parameter is optional.

includedPackages

string

Specifies a pattern for a package name or an explicit package name on which you want the archive policy to run. Only one pattern or explicit name can be entered. To include all packages, use "**". For example: "includedPackages": ["**"]

This parameter is mandatory.

excludedPackages

string

Specifies explicit package names that you want to be excluded from the policy. Only explicit names (and not patterns) are accepted. This parameter is optional.

includeAllProjects

boolean

If true the policy will run on all Artifactory projects. The default value is false. This parameter is optional.

Note

This parameter is relevant only on the global level, for Platform Admins.

includedProjects

string

The name(s) of the project(s) on which the policy will run.

Note

This parameter is relevant only on the global level, for Platform Admins.

createdBeforeInMonths

integer

The archive policy will archive packages based on how long ago they were created. For example, if this field is 2 then packages created more than 2 months ago will be archived as part of the policy.

Note

  • A policy must use one of the three settings: createdBeforeInMonths, lastDownloadedBeforeInMonths, or keepLastNVersions.

  • createdBeforeInMonths, and lastDownloadedBeforeInMonths can be used together, but they cannot be used with keepLastNVersions. Meaning, use either createdBeforeInMonths and lastDownloadedBeforeInMonths (or just one of them), or use keepLastNVersions.

lastDownloadedBeforeInMonths

integer

The archive policy will archive packages based on how long ago they were downloaded. For example, if this field is 5 then packages downloaded more than 5 months ago will be archived as part of the policy.

keepLastNVersions

integer

The number of latest versions to keep. The archive policy will remove all versions prior to this number. The latest version is always excluded.

Note

  • Versions are determined by creation date.

  • Not all package types support this condition. For information on which package types support this condition, click here.Package Types Coverage

Response Error Codes

Code

Description

400

Validation errors.

401

Bad Credentials.

403

Unauthorized.

500

Internal server error.