Updated on 2022-02-22 GMT+08:00

Creating a Policy

Function

URI

POST /v3/{project_id}/policies

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

Obtained by calling the corresponding IAM API. If the request is successfully processed, the value of X-Subject-Token included in the response header is the token value.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

policy

Yes

PolicyCreate object

Request body for creating a policy

Table 4 PolicyCreate

Parameter

Mandatory

Type

Description

enabled

No

Boolean

Whether to enable the policy

Default: true

name

Yes

String

Specifies the policy name. The value consists of 1 to 64 characters and can contain only letters, digits, underscores (_), and hyphens (-).

Minimum: 1

Maximum: 64

operation_definition

Yes

PolicyoODCreate object

Scheduling parameter

operation_type

Yes

String

Policy type

Enumeration values:

  • backup

  • replication

trigger

Yes

PolicyTriggerReq object

Time rule for the policy execution

Table 5 PolicyoODCreate

Parameter

Mandatory

Type

Description

day_backups

No

Integer

Specifies the number of retained daily backups. The latest backup of each day is saved in the long term. This parameter can be effective together with the maximum number of retained backups specified by max_backups. The value ranges from 0 to 100. If this parameter is configured, timezone is mandatory.

Minimum: 0

Maximum: 100

max_backups

No

Integer

Maximum number of retained backups. The value can be -1 or ranges from 0 to 99999. If the value is set to -1, the backups will not be cleared even though the configured retained backup quantity is exceeded. If this parameter and retention_duration_days are both left blank, the backups will be retained permanently.

Minimum: 1

Maximum: 99999

Default: -1

month_backups

No

Integer

Specifies the number of retained monthly backups. The latest backup of each month is saved in the long term. This parameter can be effective together with the maximum number of retained backups specified by max_backups. The value ranges from 0 to 100. If this parameter is configured, timezone is mandatory.

Minimum: 0

Maximum: 100

retention_duration_days

No

Integer

Duration of retaining a backup, in days. The maximum value is 99999. -1 indicates that the backups will not be cleared based on the retention duration. If this parameter and max_backups are left blank at the same time, the backups will be retained permanently.

Minimum: 1

Maximum: 99999

Default: -1

timezone

No

String

Time zone where the user is located, for example, UTC+08:00. Set this parameter only after you have configured any of the parameters day_backups, week_backups, month_backups, year_backups.

week_backups

No

Integer

Specifies the number of retained weekly backups. The latest backup of each week is saved in the long term. This parameter can be effective together with the maximum number of retained backups specified by max_backups. The value ranges from 0 to 100. If this parameter is configured, timezone is mandatory.

year_backups

No

Integer

Specifies the number of retained yearly backups. The latest backup of each year is saved in the long term. This parameter can be effective together with the maximum number of retained backups specified by max_backups. The value ranges from 0 to 100. If this parameter is configured, timezone is mandatory.

Minimum: 0

Maximum: 100

Table 6 PolicyTriggerReq

Parameter

Mandatory

Type

Description

properties

Yes

PolicyTriggerPropertiesReq object

Scheduler attributes

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Type

Description

policy

Policy object

Response to the request for creating a policy

Table 8 Policy

Parameter

Type

Description

enabled

Boolean

Whether the policy is enabled

id

String

Policy ID

name

String

Policy Name

operation_definition

PolicyoODCreate object

Policy attributes

operation_type

String

Policy type

Enumeration values:

  • backup

  • replication

trigger

PolicyTriggerResp object

Time scheduling rule for the policy

associated_vaults

Array of PolicyAssociateVault objects

Associated vault

Table 9 PolicyoODCreate

Parameter

Type

Description

day_backups

Integer

Specifies the number of retained daily backups. The latest backup of each day is saved in the long term. This parameter can be effective together with the maximum number of retained backups specified by max_backups. The value ranges from 0 to 100. If this parameter is configured, timezone is mandatory.

Minimum: 0

Maximum: 100

max_backups

Integer

Maximum number of retained backups. The value can be -1 or ranges from 0 to 99999. If the value is set to -1, the backups will not be cleared even though the configured retained backup quantity is exceeded. If this parameter and retention_duration_days are both left blank, the backups will be retained permanently.

Minimum: 1

Maximum: 99999

Default: -1

month_backups

Integer

Specifies the number of retained monthly backups. The latest backup of each month is saved in the long term. This parameter can be effective together with the maximum number of retained backups specified by max_backups. The value ranges from 0 to 100. If this parameter is configured, timezone is mandatory.

Minimum: 0

Maximum: 100

retention_duration_days

Integer

Duration of retaining a backup, in days. The maximum value is 99999. -1 indicates that the backups will not be cleared based on the retention duration. If this parameter and max_backups are left blank at the same time, the backups will be retained permanently.

Minimum: 1

Maximum: 99999

Default: -1

timezone

String

Time zone where the user is located, for example, UTC+08:00. Set this parameter only after you have configured any of the parameters day_backups, week_backups, month_backups, year_backups.

week_backups

Integer

Specifies the number of retained weekly backups. The latest backup of each week is saved in the long term. This parameter can be effective together with the maximum number of retained backups specified by max_backups. The value ranges from 0 to 100. If this parameter is configured, timezone is mandatory.

year_backups

Integer

Specifies the number of retained yearly backups. The latest backup of each year is saved in the long term. This parameter can be effective together with the maximum number of retained backups specified by max_backups. The value ranges from 0 to 100. If this parameter is configured, timezone is mandatory.

Minimum: 0

Maximum: 100

Table 10 PolicyTriggerResp

Parameter

Type

Description

id

String

Scheduler ID

name

String

Scheduler name

properties

PolicyTriggerPropertiesResp object

Scheduler attributes

type

String

Scheduler type. Currently, only time (periodic scheduling) is supported.

Enumeration values:

  • time

Table 11 PolicyTriggerPropertiesResp

Parameter

Type

Description

start_time

String

Start time of the scheduler, for example, 2020-01-08 09:59:49

Table 12 PolicyAssociateVault

Parameter

Type

Description

destination_vault_id

String

ID of the associated remote vault

vault_id

String

Vault ID

Example Requests

POST https://{endpoint}/v3/f841e01fd2b14e7fa41b6ae7aa6b0594/policies

{
  "policy" : {
    "enabled" : true,
    "name" : "policy001",
    "operation_definition" : {
      "day_backups" : 0,
      "month_backups" : 0,
      "retention_duration_days" : 1,
      "timezone" : "UTC+08:00",
      "week_backups" : 0,
      "year_backups" : 0
    },
    "operation_type" : "backup",
    "trigger" : {
      "properties" : {
        "pattern" : [ "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYHOUR=14;BYMINUTE=00" ]
      }
    }
  }
}

Example Responses

Status code: 200

OK

{
  "policy" : {
    "name" : "policy001",
    "enabled" : true,
    "trigger" : {
      "properties" : {
        "pattern" : [ "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYHOUR=14;BYMINUTE=00" ],
        "start_time" : "2019-05-08 06:57:05"
      },
      "type" : "time",
      "id" : "d67269a6-5369-42d7-8150-5254bd446328",
      "name" : "default"
    },
    "operation_definition" : {
      "retention_duration_days" : 1,
      "year_backups" : 0,
      "day_backups" : 0,
      "month_backups" : 0,
      "week_backups" : 0,
      "timezone" : "UTC+08:00"
    },
    "operation_type" : "backup",
    "id" : "cbb3ce6f-3332-4e7c-b98e-77290d8471ff"
  }
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.