github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/cts/v3/keyevent/Create.go (about) 1 package keyevent 2 3 import ( 4 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/build" 6 ) 7 8 type CreateNotificationOpts struct { 9 // Notification name. 10 NotificationName string `json:"notification_name"` 11 // Operation type. Possible options include complete and customized. 12 // If you choose complete, you do not need to specify operations and notify_user_list, 13 // and notifications will be sent when any supported operations occur on any of the connected cloud services. 14 // If you choose customized, notifications will be sent when operations defined in operations occur. 15 // Enumerated values: 16 // complete 17 // customized 18 OperationType string `json:"operation_type"` 19 // Operation list. 20 Operations []Operations `json:"operations,omitempty"` 21 // List of users whose operations will trigger notifications. 22 // Currently, up to 50 users in 10 user groups can be configured. 23 NotifyUserList []NotificationUsers `json:"notify_user_list,omitempty"` 24 // Topic URN. 25 // To obtain the topic_urn, call the SMN API for querying topics. 26 // Example URN: urn:smn:regionId:f96188c7ccaf4ffba0c9aa149ab2bd57:test_topic_v2 27 TopicId string `json:"topic_id,omitempty"` 28 } 29 30 type Operations struct { 31 // 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. 32 // For cloud services that can be connected with CTS, see section "Supported Services and Operations" in the Cloud Trace Service User Guide. 33 ServiceType string `json:"service_type"` 34 // Resource type. 35 ResourceType string `json:"resource_type"` 36 // Trace name. 37 TraceNames []string `json:"trace_names"` 38 } 39 40 type NotificationUsers struct { 41 // IAM user group. 42 UserGroup string `json:"user_group"` 43 // IAM user. 44 UserList []string `json:"user_list"` 45 } 46 47 func Create(client *golangsdk.ServiceClient, opts CreateNotificationOpts) (*NotificationResponse, error) { 48 b, err := build.RequestBody(opts, "") 49 if err != nil { 50 return nil, err 51 } 52 53 // POST /v3/{project_id}/notifications 54 raw, err := client.Post(client.ServiceURL("notifications"), b, nil, nil) 55 return extra(err, raw) 56 }