# Querying the Backup Policy List

#### Function

This API is used to query the backup policy list. Filtering parameters are supported.

#### URI

- URI format

  GET https://{endpoint}/v1/{project_id}/policies

- Parameter description

  Table 1 Parameter description
  Parameter | Mandatory | Type | Description
  --- | --- | --- | ---
  project_id | Yes | String | Project ID

#### Request

- Parameter description

  Table 2 Parameter description
  Parameter | Mandatory | Type | Description
  --- | --- | --- | ---
  limit | No | Integer | Number of resources displayed per page. The value must be a positive integer. The value defaults to 1000.
  marker | No | String | ID of the last record displayed on the previous page when pagination query is applied

  sort

  No

  String

  The value of sort is a group of properties separated by commas (,) and sorting directions. The value format is <key1>[:<direction>],<key2>[:<direction>], where the value of direction is asc (in ascending order) or desc (in descending order). If the parameter direction is not specified, backup policies are sorted in descending order by time. The value of sort contains a maximum of 255 characters.

  name | No | String | Exact matching based on field name
  all_tenants | No | Boolean | Whether backup policies of all tenants can be queried This parameter is only available for administrators.
  offset | No | Integer | Offset value, which is a positive integer.

- Parameter description

None

- Example request

      Querying all backup policies:
      GET https://{endpoint}/v1/{project_id}/policies
      Querying backup policies with certain conditions:
      GET https://{endpoint}/v1/{project_id}/policies?sort=created_at%3Aasc&limit=3&offset=3

#### Response

- Parameter description

  Table 3 Parameter description
  Parameter | Type | Description
  --- | --- | ---
  policies | List<policy_resp> | For details, see the policy_resp field description.

- Parameter description of field policy_resp

  Table 4 Parameter description of field policy_resp
  Parameter | Type | Description
  --- | --- | ---
  created_at | String | Creation time, for example, 2017-04-18T01:21:52.701973
  description | String | Backup policy description The value consists of 0 to 255 characters and must not contain a greater-than sign (>) or less-than sign (<).
  id | String | Backup policy ID
  name | String | Backup policy name The value consists of 1 to 255 characters and can contain only letters, digits, underscores (_), and hyphens (-).
  parameters | policy_param | Parameters of a backup policy
  project_id | String | Project ID
  provider_id | String | Backup provider ID, which specifies whether the backup object is a server or disk. This parameter has a fixed value. For CSBS, the value is fc4d5750-22e7-4798-8a46-f48f62c4c1da.
  resources | List<resource> | Backup object list
  scheduled_operations | List<scheduled_operation_resp> | Scheduling period list
  status | String | Backup policy status
  tags | List<resource_tag> | Tag list Keys in the tag list must be unique.

- Parameter description of field policy_param

  Table 5 Parameter description of field policy_param
  Parameter | Type | Description
  --- | --- | ---
  common | common_param | General backup policy parameters, which are blank by default

- Parameter description of field resource

  Table 6 Parameter description of field resource
  Parameter | Type | Description
  --- | --- | ---
  id | String | Backup object ID
  type | String | Entity object type of backup objects The value is fixed at OS::Nova::Server (ECSs).
  name | String | Backup object name
  extra_info | Dict | Additional information about the backup object

- Parameter description of field scheduled_operation_resp

  Table 7 Parameter description of field scheduled_operation_resp
  Parameter | Type | Description
  --- | --- | ---
  description | String | Scheduling period description The value consists of 0 to 255 characters and must not contain a greater-than sign (>) or less-than sign (<).
  enabled | Boolean | Whether the scheduling period is enabled The default value is true. If it is set to false, automatic scheduling is disabled but manual scheduling is supported.
  name | String | Scheduling period name The value consists of 1 to 255 characters and can contain only letters, digits, underscores (_), and hyphens (-).
  operation_type | String | Operation type Enumeration values: backup
  operation_definition | operation_definition | Scheduling period parameters
  trigger | trigger_resp | Scheduling policy
  id | String | Scheduling period ID

- Parameter description of field operation_definition

  Table 8 Parameter description of field operation_definition
  Parameter | Type | Description
  --- | --- | ---
  max_backups | Integer | Maximum number of backups that can be automatically created for a backup object. The value can be -1 or ranges from 0 to 99999. If the value is set to -1, backups will not be cleared by quantity limit.
  retention_duration_days | Integer | Duration of retaining a backup, in days. The value can be -1 or ranges from 0 to 99999. If the value is set to -1, backups will not be cleared by retention duration.
  permanent | Boolean | Whether backups are permanently retained
  plan_id | String | Backup policy ID
  provider_id | String | Backup provider ID, which specifies whether the backup object is a server or disk. This parameter has a fixed value. For CSBS, the value is fc4d5750-22e7-4798-8a46-f48f62c4c1da.

- Parameter description of field trigger_resp

  Table 9 Parameter description of field trigger_resp
  Parameter | Type | Description
  --- | --- | ---
  properties | trigger_properties_resp | Scheduler properties
  id | String | Scheduler ID
  name | String | Scheduler name
  type | String | Scheduling type

- Parameter description of field trigger_properties_resp

  Table 10 Parameter description of field trigger_properties_resp
  Parameter | Type | Description
  --- | --- | ---

  pattern

  String

  Scheduling policy of the scheduler

  The value consists of a maximum of 10,240 characters. The scheduling policy complies with iCalendar RFC 2445, but it supports only four parameters, which are FREQ, BYDAY, BYHOUR, and BYMINUTE. FREQ can be set to WEEKLY and DAILY, BYDAY can be set to MO, TU, WE, TH, FR, SA, and SU (seven days of a week), BYHOUR ranges from 0 hours to 23 hours, and BYMINUTE ranges from 0 minutes to 59 minutes. The scheduling interval must not be less than 1 hour. A maximum of 24 time points are allowed in a day.

  start_time | String | Start time of the scheduler, for example, 2017-03-07 09:31:08
  format | String | Scheduler type

- Parameter description of field resource_tag

  Table 11 Parameter description of field resource_tag
  Parameter | Type | Description
  --- | --- | ---
  key | String | Tag key It consists of up to 36 characters. It cannot be an empty string. It can contain only letters, digits, hyphens (-), and underscores (_).
  value | String | Tag value It consists of up to 43 characters. It can be an empty string. It can contain only letters, digits, hyphens (-), and underscores (_).

- Example response

      {
        "policies" : [ {
          "created_at" : "2017-03-07T09:31:08.265000",
          "description" : "My plan",
          "id" : "27b11f3f-578d-4464-89d1-7c6d5894f753",
          "name" : "my-plan",
          "parameters" : {
            "common" : {
            }
          },
          "project_id" : "tenant",
          "provider_id" : "c714180d-ea34-4b13-9a5e-577c7c416eec",
          "resources" : [ {
            "id" : "45baf976-c20a-4894-a7c3-c94b7376bf55",
            "name" : "resource1",
            "type" : "OS::Nova::Server",
            "extra_info" : {
          }
          }, {
            "id" : "5aa119a8-d25b-45a7-8d1b-88e127885635",
            "name" : "resource2",
            "type" : "OS::Nova::Server",
            "extra_info" : {
          }
          } ],
          "scheduled_operations" : [ {
            "description" : "My backup policy",
            "enabled" : true,
            "id" : "3b2fdf8c-2cc2-4887-9605-a8443922f6f2",
            "name" : "my-backup-policy",
            "operation_definition" : {
              "max_backups" : "20",
              "plan_id" : "27b11f3f-578d-4464-89d1-7c6d5894f753",
              "provider_id" : "c714180d-ea34-4b13-9a5e-577c7c416eec"
            },
            "operation_type" : "backup",
            "trigger" : {
              "id" : "f1246246-ec6a-4e9a-917e-d050dc2808c9",
              "name" : "default",
              "properties" : {
                "pattern" : "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nRRULE:FREQ=WEEKLY;BYDAY=TH;BYHOUR=12;BYMINUTE=27\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n",
                "start_time" : "2017-03-07 09:31:08",
                "format": "ical"
              },
              "type" : "time"
            },
            "trigger_id" : "f1246246-ec6a-4e9a-917e-d050dc2808c9"
          } ],
          "status" : "disabled"
        } ]
      }

#### Status Codes

- Normal

  Status Code | Description
  --- | ---
  200 | OK

- Abnormal

  Status Code | Description
  --- | ---
  400 | Invalid request parameters.
  401 | Authentication failed.
  403 | No operation permission.
  404 | Requested object not found.
  500 | Service internal error.
  503 | Service unavailable.

#### Error Codes

For details, see Error Codes.

Parent topic: Backup Policy Management