Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: Ying, Jiayu <jiayuying1@huawei.com> Co-committed-by: Ying, Jiayu <jiayuying1@huawei.com>
33 KiB
Creating a Key Event Notification
Function
SMS, email, or HTTP/HTTPS notifications can be sent through pre-configured SMN topics to subscribers when key operations occur. This helps you detect high-risk operations promptly. Notifications can also be used as triggers for specific operations or to connect to your own audit system.
URI
POST /v3/{project_id}/notifications
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. For details, see section "Obtaining the Account ID and Project ID" in Cloud Trace Service API Reference. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
notification_name |
Yes |
String |
Notification name. |
operation_type |
Yes |
String |
Operation type. Possible options include complete and customized. If you choose complete, you do not need to specify operations and notify_user_list, and notifications will be sent when any supported operations occur on any of the connected cloud services. If you choose customized, notifications will be sent when operations defined in operations occur. Enumerated values:
|
operations |
No |
Array of Operations objects |
Operation list. |
notify_user_list |
No |
Array of NotificationUsers objects |
List of users whose operations will trigger notifications. Currently, up to 50 users in 10 user groups can be configured. |
topic_id |
No |
String |
Topic URN.
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
service_type |
Yes |
String |
Cloud service. The value must be the acronym of a cloud service that has been connected with CTS. It is a word composed of uppercase letters. For cloud services that can be connected with CTS, see section "Supported Services and Operations" in the Cloud Trace Service User Guide. |
resource_type |
Yes |
String |
Resource type. |
trace_names |
Yes |
Array of strings |
Trace name. |
Response Parameters
Status code: 201
Parameter |
Type |
Description |
---|---|---|
notification_name |
String |
Notification name. |
operation_type |
String |
Operation type. Possible options include complete and customized. Enumerated values:
|
operations |
Array of Operations objects |
Operation list. |
notify_user_list |
Array of NotificationUsers objects |
List of users whose operations will trigger notifications. Currently, up to 50 users in 10 user groups can be configured. |
status |
String |
Notification status. Possible options include enabled and disabled. Enumerated values:
|
topic_id |
String |
Unique resource ID of an SMN topic. You can obtain the ID by querying the topic list. |
notification_id |
String |
Unique notification ID. |
notification_type |
String |
Notification type. Enumerated value:
|
project_id |
String |
Project ID. |
create_time |
Long |
Time when a notification rule was created. |
Parameter |
Type |
Description |
---|---|---|
service_type |
String |
Cloud service. The value must be the acronym of a cloud service that has been connected with CTS. It is a word composed of uppercase letters. For cloud services that can be connected with CTS, see section "Supported Services and Operations" in the Cloud Trace Service User Guide. |
resource_type |
String |
Resource type. |
trace_names |
Array of strings |
Trace name. |
Parameter |
Type |
Description |
---|---|---|
user_group |
String |
IAM user group. |
user_list |
Array of strings |
IAM user. |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. Format: CTS.XXX. |
error_msg |
String |
Error description. |
Example Request
- Creating a custom key event notification
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:{regionid}:24edf66e79d04187acb99a463e610764:test" }
- Creating a complete key event notification
POST https://{endpoint}/v3/{project_id}/notifications { "notification_name": "test", "operation_type": "complete", "topic_id": "urn:smn:{regionid}:24edf66e79d04187acb99a463e610764:test" }
Example Response
Status code: 201
The creation is successful.
{ "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:{regionid}:24edf66e79d04187acb99a463e610764:test" }
Status Codes
Status Code |
Description |
---|---|
201 |
The creation is successful. |
400 |
The server failed to process the request. |
401 |
The request is rejected due to authentication failure. |
403 |
The server understood the request but refused to authorize it. |
404 |
The server failed to find the requested resource or some key event notifications failed to be deleted. |
500 |
The request failed to be executed or some trackers failed to be deleted. |
503 |
The requested service is unavailable. The client should not repeat the request without modifications. |
Error Codes
See Error Codes.