-
Notifications
You must be signed in to change notification settings - Fork 11
/
requests.go
47 lines (41 loc) · 1.65 KB
/
requests.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package alarmnotifications
import (
golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
"github.com/opentelekomcloud/gophertelekomcloud/openstack"
)
// UpdateOptsBuilder allows extensions to add additional parameters to the
// Update request.
type UpdateOptsBuilder interface {
ToAlarmNotificationUpdateMap() (map[string]interface{}, error)
}
// UpdateOpts contains all the values needed to update the alarm notification.
type UpdateOpts struct {
Enabled *bool `json:"enabled" required:"true"`
TopicURN *string `json:"topic_urn" required:"true"`
SendFrequency int `json:"sendfreq" required:"true"`
Times int `json:"times" required:"true"`
Threat []string `json:"threat" required:"true"`
Locale string `json:"locale,omitempty"`
}
// ToAlarmNotificationUpdateMap casts a UpdateOpts struct to a map.
func (opts UpdateOpts) ToAlarmNotificationUpdateMap() (map[string]interface{}, error) {
return golangsdk.BuildRequestBody(opts, "")
}
// Update is an operation which modifies the attributes of the specified alarm notification.
func Update(client *golangsdk.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult) {
b, err := opts.ToAlarmNotificationUpdateMap()
if err != nil {
r.Err = err
return
}
_, r.Err = client.Put(resourceURL(client, id), b, &r.Body, &golangsdk.RequestOpts{
OkCodes: []int{200},
MoreHeaders: openstack.StdRequestOpts().MoreHeaders,
})
return
}
// List is method that can be able to list all alarm notification of WAF service
func List(client *golangsdk.ServiceClient) (r ListResult) {
_, r.Err = client.Get(listURL(client), &r.Body, openstack.StdRequestOpts())
return
}