# 查看策略列表
#### 功能说明
该接口用于查询指定项目下所有策略的详细信息。
#### URI
GET /v1/{project_id}/pe/policy
参数说明请参见[表1]。
 表1参数说明 
| 参数名称       | 是否必选 | 描述   |
|:---|:---|:---|
| project_id | 是    | 项目ID |
   
#### 请求消息
**请求消息头**
无
**请求参数**
无
**请求示例**
无
#### 响应消息
**响应参数**
响应参数如[表2]所示。
 表2响应参数 
| 参数名称         | 类型                                                                                                            | 描述         |
|:---|:---|:---|
| errorCode     | String                                                                                                        | 错误码        |
| errorMessage | String                                                                                                        | 详细信息        |
| policy       | 参见[表3] | 修改后的策略详细信息 |
   
 表3policy数据结构说明 
| 参数名称        | 参数类型                                                                                                           | 描述    |
|:---|:---|:---|
| id          | String                                                                                                                                                  | 策略ID。 |
| name        | String                                                                                                                                                  | 策略名称。 |
| policy_type | String                                                                                                                                                 | 策略类型。 |
| rule         | 参见[表4] | 触发策略的规则                 |
| create_time | String                                                                                                                                                   | 创建时间  |
| update_time | String                                                                                                                                                 | 更新时间  |
| status      | String                                                                                                                                                  | 状态    |
   
 表4rule字段数据结构说明 
| 参数名称       | 参数类型                                                                                                           | 描述                |
|:---|:---|:---|
| name       | String                                                                                                                                                 | 策略名称。           |
| conditions | 参见[表5] | 匹配条件具体内容。       |
| actions     | 参见[表6] | 指定策略匹配成功后执行的动作。 |
   
 表5conditions字段数据结构说明 
| 参数名称                | 参数类型  | 描述        |
|:---|:---|:---|
| metric_namespace   | String                                        | 命名空间      |
| metric_name        | String                                         | 指标名称      |
| metric_unit        | String                                         | 单位        |
| period              | Integer                                         | 统计周期，单位：秒 |
| evaluation_periods | Integer                                        | 连续周期数       |
| statistic          | String                                          | 统计方式      |
| metric_operation   | String                                         | 指标操作符     |
| metric_threshold   | Float | 阈值条件      |
   
 表6actions字段数据结构说明 
| 参数名称       | 参数类型                                                                                                           | 描述                         |
|:---|:---|:---|
| type        | String                                                                                                         | 扩缩容：含有k8s的表示容器应用，含有vm的表示进程应用 |
| parameters | 参见[表7] | 包含扩缩容的实例数                  |
   
 表7parameters字段数据结构说明 
| 参数名称       | 参数类型 | 描述     |
|:---|:---|:---|
| scale_unit | Integer                                       | 扩缩容实例数 |
   
**响应示例**
```
{
    "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" : "\u003e",
                        "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"
        }
    ]
}
```
#### 错误码
表8错误码 
| 错误码                | 错误信息                         | 处理措施         |
|:---|:---|:---|
| SVCSTG.PE.4031012   | Failed to verify the project ID. | 请检查对应的参数是否符合要求。 |
| SVCSTG.PE.5001203 | Query error.                   | 请联系技术支持工程师解决。 |
   
