
# 修改告警规则告警通知信息 - UpdateAlarmNotifications
#### 功能介绍
修改告警规则告警通知信息，告警策略\&资源请使用对应接口
#### 调试
您可以在[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/CES/doc?api=UpdateAlarmNotifications&version=v2)中调试该接口，支持自动认证鉴权。API Explorer可以自动生成SDK代码示例，并提供SDK代码示例调试功能。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-ces/ces_03_0045.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项                              | 访问级别  | 资源类型（\*为必须） | 条件键                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | 别名             | 依赖的授权项 |
  |:---|:---|:---|:---|:---|:---|
  | ces:alarms:putAlarmNotifications | Write | alarm \*    | - g:ResourceTag/\<tag-key\>   - g:EnterpriseProjectId    | ces:alarms:put | -      |
     
  
 
#### URI
PUT /v2/{project_id}/alarms/{alarm_id}/notifications
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|:---|:---|:---|:---|
| project_id | 是    | String | **参数解释**: 项目ID。用于明确项目归属，配置后可通过该ID查询项目下资产，可以通过调用API获取，也可以从控制台获取。获取方式请参见[获取项目ID](https://support.huaweicloud.com/api-ces/ces_03_0057.html)。 **约束限制**: 不涉及。 **取值范围**: 字符串的长度必须在 1 到 64个字符之间。 **默认取值**: 不涉及。 |
| alarm_id   | 是    | String | **参数解释**： 告警规则ID，通过[查询告警规则列表（推荐）](https://support.huaweicloud.com/api-ces/ListAlarmRules.html)接口获取告警规则ID。 **约束限制**： 不涉及。 **取值范围**： 以al开头，后跟22位字母或数字。 **默认取值**： 不涉及。         |
   
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|:---|:---|:---|:---|
| Content-Type | 否    | String | **参数解释**: 发送的实体的MIME类型。 **约束限制**: 不涉及。 **取值范围**: 最小字符数量为1，最大为64。 **默认取值**: 默认使用application/json; charset=UTF-8。                                                                            |
| X-Auth-Token | 否    | String | **参数解释**: 用户Token。Token认证，具体操作请参考[认证鉴权](https://support.huaweicloud.com/api-ces/ces_03_0011.html)。 **约束限制**: 不涉及。 **取值范围**: 最小字符数量为1，最大为16384。 **默认取值**: 不涉及。 |
   
表3请求Body参数 
| 参数                      | 是否必选 | 参数类型                                                                                                          | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|:---|:---|:---|:---|
| notification_enabled    | 是    | Boolean                                                                                                       | **参数解释**： 是否开启告警通知。 **约束限制**： 不涉及。 **取值范围**： 布尔值。 - true：开启告警。   - false：不开启告警。    **默认取值**： 不涉及。 |
| alarm_notifications     | 否    | Array of [Notification] objects | **参数解释**： 触发告警时，通知组/主题订阅的信息。 **约束限制**： 包含的通知对象信息的数量最多为10个，最少为0个。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ok_notifications        | 否    | Array of [Notification] objects | **参数解释**： 告警恢复时，通知组/主题订阅的信息。 **约束限制**： 包含的通知对象信息的数量最多为10个，最少为0个。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| notification_begin_time | 否    | String                                                                                                        | **参数解释**： 告警通知开启时间。 **约束限制**： 当notification_enabled字段为true时，该字段必填。 **取值范围**： 只能包含数字、":"，长度为\[1,64\]个字符。 **默认取值**： 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| notification_end_time   | 否    | String                                                                                                        | **参数解释**： 告警通知关闭时间。 **约束限制**： 当notification_enabled字段为true时，该字段必填。 **取值范围**： 只能包含数字、":"，长度为\[1,64\]个字符。 **默认取值**： 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| effective_timezone      | 否    | String                                                                                                        | **参数解释**： 时区，形如："GMT-08:00"、"GMT+08:00"、"GMT+0:00"。 **约束限制**： 不涉及。 **取值范围**： 长度为\[1,16\]个字符。 **默认取值**： 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
   
 表4Notification 
| 参数                | 是否必选 | 参数类型             | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
|:---|:---|:---|:---|
| type              | 是    | String           | **参数解释**： 通知类型。 **约束限制**： 不涉及。 **取值范围**： 枚举值。 - notification：通知组或主题订阅。   - contact：云账号联系人。   - contactGroup：（已废弃）通知组。   - autoscaling：AS通知，只在AS中使用。   - groupwatch：已废弃，不推荐使用。   - ecsRecovery：已废弃，不推荐使用。   - iecAction：已废弃，不推荐使用。    **默认取值**： 不涉及。 |
| notification_list | 是    | Array of strings | **参数解释**： 告警状态发生变化时，被通知对象的列表。topicUrn可从SMN获取，具体操作请参考查询Topic列表。 **约束限制**： 当type为notification时，notification_list列表不能为空；当type为autoscaling时，列表必须为\[\]。若notification_enabled为true，对应的alarm_notifications、ok_notifications至少有一个不能为空。若alarm_notifications、ok_notification同时存在时，notification_list值保持一致。最多包含20个通知对象，最少可以为0个。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
   
#### 响应参数
**状态码：200**
表5响应Body参数 
| 参数                      | 参数类型                                                                                                                   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|:---|:---|:---|
| notification_enabled    | Boolean                                                                                                                | **参数解释**： 是否开启告警通知。 **取值范围**： 布尔值。 - true：开启告警。   - false：不开启告警。                                                                                                                                                                                                                                                    |
| alarm_notifications     | Array of [NotificationResp] objects | **参数解释**： 触发告警时，通知组/主题订阅的信息。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ok_notifications        | Array of [NotificationResp] objects | **参数解释**： 告警恢复时，通知组/主题订阅的信息。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| notification_begin_time | String                                                                                                                 | **参数解释**： 告警通知开启时间。如 00:00 **取值范围**： 只能包含数字、":"，长度为\[1,64\]个字符。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| notification_end_time   | String                                                                                                                 | **参数解释**： 告警通知关闭时间。如 08:00 **取值范围**： 只能包含数字、":"，长度为\[1,64\]个字符。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| effective_timezone      | String                                                                                                                 | **参数解释**： 时区，形如："GMT-08:00"、"GMT+08:00"、"GMT+0:00"。 **取值范围**： 长度为\[1,16\]个字符。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| notification_manner     | String                                                                                                                 | **参数解释**： 告警的通知方式 **取值范围**： - NOTIFICATION_GROUP: 通知组   - TOPIC_SUBSCRIPTION: 主题订阅   - NOTIFICATION_POLICY：通知策略    |
| notification_policy_ids | Array of strings                                                                                                       | **参数解释**： 关联的通知策略ID列表                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
   
 表6NotificationResp 
| 参数                | 参数类型             | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
|:---|:---|:---|
| type              | String           | **参数解释**： 通知类型。 **取值范围**： 枚举值。 - notification：通知组或主题订阅。   - contact：云账号联系人。   - contactGroup：（已废弃）通知组。   - autoscaling：AS通知，只在AS中使用，不推荐客户使用。   - groupwatch：已废弃，不推荐使用。   - ecsRecovery：已废弃，不推荐使用。   - iecAction：已废弃，不推荐使用。    |
| notification_list | Array of strings | **参数解释**： 告警状态发生变化时，被通知对象的列表。topicUrn可从SMN获取，具体操作请参考查询Topic列表。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
   
**状态码：400**
表7响应Body参数 
| 参数         | 参数类型   | 描述                                                                                                                                                                                                                                                                            |
|:---|:---|:---|
| error_code | String | **参数解释**： 用于标识请求异常的具体原因。 **取值范围**： 字符串长度为0到256个字符。  |
| error_msg  | String | **参数解释**： 用于描述请求异常的具体信息。 **取值范围**： 字符串长度为0到256个字符。  |
| request_id | String | **参数解释**： 用于唯一标识一次请求，便于问题追踪。 **取值范围**： 字符串长度为0到256个字符。 |
   
**状态码：500**
表8响应Body参数 
| 参数         | 参数类型   | 描述                                                                                                                                                                                                                                                                                |
|:---|:---|:---|
| error_code | String | **参数解释**： 用于标识请求异常的具体原因。 **取值范围**： 字符串长度为0到256个字符。     |
| error_msg  | String | **参数解释**： 用于描述请求异常的具体信息。 **取值范围**： 字符串长度为0到256个字符。     |
| request_id | String | **参数解释**： 用于唯一标识一次请求，便于问题追踪。 **取值范围**： 字符串长度为0到256个字符。 |
   
#### 请求示例
修改告警规则告警通知信息
```
{
  "notification_enabled" : true,
  "alarm_notifications" : [ {
    "type" : "notification",
    "notification_list" : [ "urn:smn:cn-north-7:65c438cab60xxxxxxx:CES_notification_group_MGj4AJ03X" ]
  } ],
  "ok_notifications" : [ {
    "type" : "notification",
    "notification_list" : [ "urn:smn:cn-north-7:65c438cab60xxxxxxx:CES_notification_group_MGj4AJ03X" ]
  } ],
  "notification_begin_time" : "00:00",
  "notification_end_time" : "23:59"
}
```
#### 响应示例
**状态码：200**
修改告警规则告警通知信息成功
```
{
  "notification_enabled" : true,
  "alarm_notifications" : [ {
    "type" : "notification",
    "notification_list" : [ "urn:smn:cn-north-7:65c438cab60xxxxxxx:CES_notification_group_MGj4AJ03X" ]
  } ],
  "ok_notifications" : [ {
    "type" : "notification",
    "notification_list" : [ "urn:smn:cn-north-7:65c438cab60xxxxxxx:CES_notification_group_MGj4AJ03X" ]
  } ],
  "notification_begin_time" : "00:00",
  "notification_end_time" : "23:59",
  "effective_timezone" : "GMT-08:00",
  "notification_manner" : "NOTIFICATION_GROUP",
  "notification_policy_ids" : [ ]
}
```
#### 状态码
| 状态码 | 描述             |
|:---|:---|
| 200 | 修改告警规则告警通知信息成功 |
| 400 | 参数校验失败         |
| 500 | 系统内部错误         |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-ces/ErrorCode.html)。
