Updated on 2024-04-15 GMT+08:00

Querying the Policy List

Function

This API is used to query details about all policies in a specified project.

URI

GET /v1/{project_id}/pe/policy

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 from IAM.

Content-Type

Yes

String

Content type, which is application/json.

Enumeration values:

  • application/json

resourcetype

Yes

String

Resource type. Value: nod or app.

Enumeration values:

  • node

  • app

Cluster-Id

Yes

String

Cluster ID.

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMessage

String

Details.

policies

Array of AllPolicyContext objects

Details about a modified policy.

Table 4 AllPolicyContext

Parameter

Type

Description

id

String

Policy ID.

group_id

String

Policy group ID.

name

String

Policy name.

policy_type

String

Policy type.

rule

AllRule object

Policy trigger rule.

create_time

String

Creation time.

update_time

String

Update time.

status

String

Status.

Table 5 AllRule

Parameter

Type

Description

conditions

Array of AllConditions objects

Condition contents. When an alarm policy is used, its conditions cannot conflict. Example: You cannot set a metric greater than 10% in one condition and smaller than 20% in another condition.

actions

Array of Action objects

Action executed after a specified policy is matched.

name

String

Policy name.

Table 6 AllConditions

Parameter

Type

Description

launch_time

String

Time when the policy is triggered. This parameter is available when policy_type is set to SCHEDULED or RECURRENCE.

recurrence_type

String

Period type. This parameter is left blank for scheduled policies. This parameter is available when policy_type is set to SCHEDULED or RECURRENCE.

recurrence_value

String

Specific trigger time of a periodic policy. This parameter is left blank for scheduled policies. This parameter is available when policy_type is set to SCHEDULED or RECURRENCE.

start_time

Integer

Start time of the periodic policy. This parameter is left blank for the scheduled policy. This parameter is available when policy_type is set to SCHEDULED or RECURRENCE.

end_time

Integer

End time of the periodic policy. This parameter is left blank for the scheduled policy. This parameter is available when policy_type is set to SCHEDULED or RECURRENCE.

time_zone

String

Time zone. This parameter is available when policy_type is set to SCHEDULED or RECURRENCE.

metric_namespace

String

Metric namespace. This parameter is available when policy_type is set to ALARM.

Enumeration values:

  • PAAS.CONTAINER

  • PAAS.CUSTOMMETRICS

metric_name

String

Metric name. This parameter is available when policy_type is set to ALARM.

Enumeration values:

  • ^[a-zA-Z_:][a-zA-Z0-9_:]{0

  • 254}$

metric_unit

String

Unit. Note: The value is retrieved from an AMS API and varies with the metric name. This parameter is available when policy_type is set to ALARM.

period

Integer

Statistical period (unit: s). This parameter is available when policy_type is set to ALARM.

Enumeration values:

  • 20

  • 60

  • 300

  • 900

  • 1800

  • 3600

evaluation_periods

Integer

Number of consecutive periods. This parameter is available when policy_type is set to ALARM.

Enumeration values:

  • 1

  • 2

  • 3

  • 4

  • 5

statistic

String

Statistic. This parameter is available when policy_type is set to ALARM.

Enumeration values:

  • average

metric_operation

String

Metric operator. Option: > or <. For example, you can use > in a threshold criterion (when the value of a metric is greater than metric_thresholdUpdate) to trigger actions. This parameter is available when policy_type is set to ALARM.

Enumeration values:

  • >

  • <

metric_threshold

Integer

Threshold condition. This parameter is available when policy_type is set to ALARM.

Table 7 Action

Parameter

Type

Description

type

String

scale_out_k8s and scale_out_vm indicate a scale-out. scale_in_k8s and scale_in_vm indicate a scale-in. Note: The value containing k8s indicates a scale-in or -out for containerized applications and that containing vm indicates a scale-in or -out for process applications.

Enumeration values:

  • scale_out_k8s

  • scale_out_vm

  • scale_in_k8s

  • scale_in_vm

parameters

Array of Parameter objects

Number of scale-in or -out instances.

Table 8 Parameter

Parameter

Type

Description

scale_unit

Integer

Number of scale-in or -out instances. The value is between the minimum number of instances to the maximum number of instances in a policy group.

Example Requests

None

Example Responses

Status code: 200

OK

The request is successful.

{
  "errorCode" : "SVCSTG.PE.0",
  "errorMessage" : "",
  "policies" : [ {
    "id" : "8accffb6-e0ed-4433-b216-ccf6960eb1ad",
    "name" : "alarm",
    "group_id" : "77c37e1f-aa0c-438d-8445-39b3997786a2",
    "policy_type" : "ALARM",
    "rule" : {
      "name" : "",
      "conditions" : [ {
        "metric_namespace" : "PAAS.CONTAINER",
        "metric_name" : "cpuCoreLimit",
        "metric_unit" : "Percent",
        "period" : 60,
        "evaluation_periods" : 1,
        "statistic" : "average",
        "metric_operation" : ">",
        "metric_threshold" : 100,
        "metric_dimensions" : null
      } ],
      "actions" : [ {
        "type" : "scale_out_k8s",
        "parameters" : {
          "scale_unit" : 1
        }
      } ]
    },
    "create_time" : "2017-12-21T09:13:42Z",
    "update_time" : "2017-12-21T09:13:42Z",
    "status" : "enabled"
  }, {
    "id" : "9aafbd3d-eac4-4a92-a342-5b6f8d60fff2",
    "name" : "dingshi2",
    "group_id" : "77c37e1f-aa0c-438d-8445-39b3997786a2",
    "policy_type" : "SCHEDULED",
    "rule" : {
      "name" : "",
      "conditions" : [ {
        "launch_time" : "2017-12-22T06:30Z",
        "recurrence_type" : "",
        "recurrence_value" : "",
        "start_time" : "",
        "end_time" : ""
      } ],
      "actions" : [ {
        "type" : "scale_set_k8s",
        "parameters" : {
          "scale_unit" : 1
        }
      } ]
    },
    "create_time" : "2017-12-21T09:14:00Z",
    "update_time" : "2017-12-21T09:14:00Z",
    "status" : "enabled"
  } ]
}

Status Codes

Status Code

Description

200

OK

The request is successful.

400

Bad Request

Invalid request. The client should not repeat the request without modifications.

401

Unauthorized

The authorization information is incorrect or invalid.

403

ForbiddenThe request is rejected. The server has received the request and understood it, but the server refuses to respond to it. The client should not repeat the request without modifications.

500

Internal Server Error

The server is able to receive the request but unable to understand the request.

503

Service Unavailable

The requested service is invalid. The client should not repeat the request without modifications.

Error Codes

See Error Codes.