创建关键操作通知
功能介绍
配置关键操作通知,可在发生特定操作时,使用预先创建好的SMN主题,向用户手机、邮箱发送消息,也可直接发送http/https消息。常用于实时感知高危操作、触发特定操作或对接用户自有审计分析系统。
调试
您可以在API Explorer中调试该接口。
URI
POST /v3/{project_id}/notifications
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID,参见《云审计服务API参考》“获取账号ID和项目ID”章节。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
notification_name |
是 |
String |
标识关键操作名称。 |
operation_type |
是 |
String |
标识操作类型。 目前支持的操作类型有完整类型(complete)和自定义类型(customized)。 完整类型下,CTS发送通知的对象为已对接服务的所有事件,此时不用指定operations和notify_user_list字段。 自定义类型下,CTS发送通知的对象是在operations列表中指定的事件。 枚举值:
|
operations |
否 |
Array of Operations objects |
操作事件列表。 |
notify_user_list |
否 |
Array of NotificationUsers objects |
通知用户列表,目前最多支持对10个用户组和50个用户发起的操作进行配置。 |
topic_id |
否 |
String |
消息通知服务的topic_urn或者函数工作流的func_urn。
|
响应参数
状态码: 201
参数 |
参数类型 |
描述 |
---|---|---|
notification_name |
String |
通知名称。 |
operation_type |
String |
操作类型,完整和自定义。 枚举值:
|
operations |
Array of Operations objects |
操作事件列表。 |
notify_user_list |
Array of NotificationUsers objects |
通知用户列表,目前最多支持对10个用户组和50个用户发起的操作进行配置。 |
status |
String |
通知状态,启用和停用。 枚举值:
|
topic_id |
String |
消息通知服务(SMN)主题的唯一的资源标识,可通过查询主题列表获取该标识。 |
notification_id |
String |
通知的唯一标识ID。 |
notification_type |
String |
通知类型,消息通知,函数触发器。 枚举值:
|
project_id |
String |
项目ID。 |
create_time |
Long |
通知规则创建时间。 |
参数 |
参数类型 |
描述 |
---|---|---|
service_type |
String |
标识云服务类型。必须为已对接CTS的云服务的英文缩写,且服务类型一般为大写字母。 已对接的云服务列表参见《云审计服务用户指南》“支持的服务”章节。 |
resource_type |
String |
标识资源类型。 |
trace_names |
Array of strings |
标识事件名称。 |
状态码: 400
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码标识,CTS.XXX。 |
error_msg |
String |
错误描述。 |
请求示例
创建完整类型关键操作通知请求样例。
POST https://{endpoint}/v3/{project_id}/notifications { "notification_name" : "test", "operation_type" : "complete", "topic_id" : "urn:smn:cn-north-7:24edf66e79d04187acb99a463e610764:test" }
创建自定义类型关键操作通知请求样例。
POST https://{endpoint}/v3/{project_id}/notifications { "notification_name" : "keyOperate_info_cfwy", "operation_type" : "customized", "operations" : [ { "service_type" : "CTS", "resource_type" : "tracker", "trace_names" : [ "createTracker", "deleteTraceker" ] }, { "service_type" : "CTS", "resource_type" : "notification", "trace_names" : [ "deleteNotification", "updateNotification" ] }, { "service_type" : "AOM", "resource_type" : "pe", "trace_names" : [ "deletePolicyGroup", "updatePolicyGroup", "createPolicyGroup" ] } ], "notify_user_list" : [ { "user_group" : "admin", "user_list" : [ "test1", "test2" ] }, { "user_group" : "CTS view", "user_list" : [ "test3", "test4" ] } ], "topic_id" : "urn:smn:cn-north-7:24edf66e79d04187acb99a463e610764:test" }
响应示例
状态码: 201
创建成功。
{ "create_time" : 1634001495876, "notification_id" : "cda8fd83-d08c-46f0-b914-1453a6a85c00", "notification_name" : "keyOperate_info_cfwy", "notification_type" : "smn", "notify_user_list" : [ { "user_group" : "admin", "user_list" : [ "test1", "test2" ] }, { "user_group" : "CTS view", "user_list" : [ "test3", "test4" ] } ], "operation_type" : "customized", "operations" : [ { "resource_type" : "tracker", "service_type" : "CTS", "trace_names" : [ "createTracker", "deleteTraceker" ] }, { "resource_type" : "notification", "service_type" : "CTS", "trace_names" : [ "deleteNotification", "updateNotification" ] }, { "resource_type" : "pe", "service_type" : "AOM", "trace_names" : [ "deletePolicyGroup", "updatePolicyGroup", "createPolicyGroup" ] } ], "project_id" : "24edf66e79d04187acb99a463e610764", "status" : "enabled", "topic_id" : "urn:smn:cn-north-7:24edf66e79d04187acb99a463e610764:test" }
状态码
状态码 |
描述 |
---|---|
201 |
创建成功。 |
400 |
服务器未能处理请求。 |
401 |
请求鉴权校验失败,访问被拒绝。 |
403 |
请求权限校验失败,访问被禁止。 |
404 |
服务器无法找到被请求的资源或部分关键操作通知删除失败。 |
500 |
服务内部异常,请求未完成;或部分追踪器删除失败。 |
503 |
被请求的服务无效。建议直接修改该请求,不要重试该请求。 |
错误码
请参见错误码。
