6.1 关键操作通知管理
6.1.1 创建关键操作通知
功能介绍
配置关键操作通知,可在发生特定操作时,使用预先创建好的SMN主题,向用户手 机、邮箱发送消息,也可直接发送http/https消息。常用于实时感知高危操作、触发特 定操作或对接用户自有审计分析系统。
调试
您可以在API Explorer中调试该接口。
URI
POST /v3/{project_id}/notifications
表6-1 路径参数
参数 是否必选 参数类型 描述
project_id 是 String 项目ID,参见《云审计服务API 参考》“获取账号ID和项目ID”
章节。
请求参数
自定义类型(customized)。 完 整类型下,CTS发送通知的对象 为已对接服务的所有事件,此时 不用指定operations和notify_user_list字段。 自定义 类型下,CTS发送通知的对象是 在operations列表中指定的事 件。
枚举值:
● complete
● customized operations 否 Array of
Operations sers objects
通知用户列表,目前最多支持对 10个用户组和50个用户发起的 操作进行配置。
topic_id 否 String 消息通知服务的topic_urn或者 函数工作流的func_urn。
● 消息通知服务的topic_urn可 以通过消息通知服务的查询 主题列表API获取,示例:
urn:smn:regionId:f96188c7c caf4ffba0c9aa149ab2bd57:t est_topic_v2。
● 函数工作流的func_urn可以 通过函数工作流的获取函数
表6-3 Operations
参数 是否必选 参数类型 描述
service_type 是 String 标识云服务类型。必须为已对接 CTS的云服务的英文缩写,且服 务类型一般为大写字母。 已对 接的云服务列表参见《云审计服 务用户指南》“支持的服务”章 节。
resource_type 是 String 标识资源类型。
trace_names 是 Array of
strings 标识事件名称。
表6-4 NotificationUsers
参数 是否必选 参数类型 描述
user_group 是 String IAM用户组。
user_list 是 Array of
strings IAM用户。
响应参数
状态码: 201
表6-5 响应 Body 参数
参数 参数类型 描述
notification_n
ame String 通知名称。
operation_typ
e String 操作类型,完整和自定义。
枚举值:
● customized
● complete operations Array of
Operations
objects操作事件列表。
notify_user_lis
t Array of
NotificationU sers objects
通知用户列表,目前最多支持对10个用户组和50 个用户发起的操作进行配置。
参数 参数类型 描述
status String 通知状态,启用和停用。
枚举值:
● enabled
● disabled
topic_id String 消息通知服务(SMN)主题的唯一的资源标识,可 通过查询主题列表获取该标识。
notification_id String 通知的唯一标识ID。
notification_ty
pe String 通知类型,消息通知,函数触发器。
枚举值:
● smn
● fun project_id String 项目ID。
create_time Long 通知规则创建时间。
表6-6 Operations
参数 参数类型 描述
service_type String 标识云服务类型。必须为已对接CTS的云服务的 英文缩写,且服务类型一般为大写字母。 已对接 的云服务列表参见《云审计服务用户指南》“支 持的服务”章节。
resource_type String 标识资源类型。
trace_names Array of
strings 标识事件名称。
表6-7 NotificationUsers
参数 参数类型 描述
user_group String IAM用户组。
user_list Array of
strings IAM用户。
状态码: 400
表6-8 响应 Body 参数
参数 参数类型 描述
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"
}
您可以在API Explorer中调试该接口。
URI
PUT /v3/{project_id}/notifications