github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/antiddos/v2/alarmreminding/requests.go (about) 1 package alarmreminding 2 3 import ( 4 "github.com/chnsz/golangsdk" 5 ) 6 7 func GetWarnAlert(client *golangsdk.ServiceClient) (r WarnAlertResult) { 8 url := GetWarnAlertURL(client) 9 _, r.Err = client.Get(url, &r.Body, nil) 10 return 11 } 12 13 type UpdateOps struct { 14 // The topic urn. 15 TopicUrn string `json:"topic_urn"` 16 17 // The display name of alert config. 18 DisplayName string `json:"display_name"` 19 20 // Alarm configuration. 21 WarnConfig *WarnConfig `json:"warn_config"` 22 } 23 24 var requestOpts = golangsdk.RequestOpts{ 25 MoreHeaders: map[string]string{"Content-Type": "application/json", "X-Language": "en-us"}, 26 } 27 28 type WarnConfig struct { 29 // Whether to enable alarm config 30 EnableAntiDDoS *bool `json:"antiDDoS,omitempty"` 31 32 // Deprecated 33 // Brute force cracking (system logins, FTP, and DB) 34 BruceForce *bool `json:"bruce_force,omitempty"` 35 36 // Deprecated 37 // Alarms about remote logins 38 RemoteLogin *bool `json:"remote_login,omitempty"` 39 40 // Deprecated 41 // Weak passwords (system and database) 42 WeakPassword *bool `json:"weak_password,omitempty"` 43 44 // Deprecated 45 // Overly high rights of a database process 46 HighPrivilege *bool `json:"high_privilege,omitempty"` 47 48 // Deprecated 49 // Web page backdoors 50 BackDoors *bool `json:"back_doors,omitempty"` 51 52 // Deprecated 53 // Reserved 54 Waf *bool `json:"waf,omitempty"` 55 56 // Deprecated 57 // Possible values: 0: indicates that alarms are sent once a day. 1: indicates that alarms are sent once every half hour. This parameter is mandatory for the Host Intrusion Detection (HID) service. 58 SendFrequency *int `json:"send_frequency,omitempty"` 59 } 60 61 type UpdateOpsBuilder interface { 62 ToUpdateMap() (map[string]interface{}, error) 63 } 64 65 func (opts UpdateOps) ToUpdateMap() (map[string]interface{}, error) { 66 b, err := golangsdk.BuildRequestBody(opts, "") 67 if err != nil { 68 return nil, err 69 } 70 return b, nil 71 } 72 73 func UpdateWarnAlert(client *golangsdk.ServiceClient, opts UpdateOpsBuilder) (r UpdateResult) { 74 reuestBody, err := opts.ToUpdateMap() 75 if err != nil { 76 r.Err = err 77 return 78 } 79 80 _, r.Err = client.Post(UpdateWarnAlertURL(client), reuestBody, &r.Body, &golangsdk.RequestOpts{ 81 MoreHeaders: requestOpts.MoreHeaders, 82 }) 83 return 84 }