github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/cts/v3/keyevent/Update.go (about) 1 package keyevent 2 3 import ( 4 "net/http" 5 6 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 7 "github.com/opentelekomcloud/gophertelekomcloud/internal/build" 8 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 9 ) 10 11 type UpdateNotificationOpts struct { 12 // Notification name. 13 NotificationName string `json:"notification_name"` 14 // Operation type. Possible options include complete and customized. 15 // If you choose complete, you do not need to specify operations and notify_user_list, 16 // and notifications will be sent when any supported operations occur on any of the connected cloud services. 17 // If you choose customized, notifications will be sent when operations defined in operations occur. 18 // Enumerated values: 19 // complete 20 // customized 21 OperationType string `json:"operation_type"` 22 // Operation list. 23 Operations []Operations `json:"operations,omitempty"` 24 // List of users whose operations will trigger notifications. 25 // Currently, up to 50 users in 10 user groups can be configured. 26 NotifyUserList []NotificationUsers `json:"notify_user_list,omitempty"` 27 // Notification status. Possible options include enabled and disabled. 28 // Enumerated values: 29 // enabled 30 // disabled 31 Status string `json:"status"` 32 // Topic URN. 33 // To obtain the topic_urn, call the SMN API for querying topics. 34 // Example URN: urn:smn:regionId:f96188c7ccaf4ffba0c9aa149ab2bd57:test_topic_v2 35 TopicId string `json:"topic_id,omitempty"` 36 // Notification ID. 37 NotificationId string `json:"notification_id"` 38 } 39 40 func Update(client *golangsdk.ServiceClient, opts UpdateNotificationOpts) (*NotificationResponse, error) { 41 b, err := build.RequestBody(opts, "") 42 if err != nil { 43 return nil, err 44 } 45 46 // PUT /v3/{project_id}/notifications 47 raw, err := client.Put(client.ServiceURL("notifications"), b, nil, &golangsdk.RequestOpts{ 48 OkCodes: []int{200}, 49 }) 50 return extra(err, raw) 51 } 52 53 func extra(err error, raw *http.Response) (*NotificationResponse, error) { 54 if err != nil { 55 return nil, err 56 } 57 58 var res NotificationResponse 59 err = extract.Into(raw.Body, &res) 60 return &res, err 61 }