-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwallarm_mode.go
56 lines (46 loc) · 1.4 KB
/
wallarm_mode.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
48
49
50
51
52
53
54
55
56
package wallarm
import (
"encoding/json"
"fmt"
)
type (
WallarmMode interface {
WallarmModeUpdate(wallarmModeBody *WallarmModeParams, clientID int) (*WallarmModeResponse, error)
WallarmModeRead(clientID int) (*WallarmModeResponse, error)
}
WallarmModeParams struct {
Mode string `json:"mode"`
}
WallarmModeResponse struct {
Status int `json:"status"`
Body WallarmModeParams `json:"body"`
}
)
// WallarmModeUpdate changes wallarm_mode state.
// API reference: https://apiconsole.eu1.wallarm.com
func (api *api) WallarmModeUpdate(wallarmModeBody *WallarmModeParams, clientID int) (*WallarmModeResponse, error) {
url := fmt.Sprintf("/v2/client/%d/rules/wallarm_mode", clientID)
rawResp, err := api.makeRequest("PUT", url, "wallarm_mode", wallarmModeBody)
if err != nil {
return nil, err
}
var resp WallarmModeResponse
if err = json.Unmarshal(rawResp, &resp); err != nil {
return nil, err
}
return &resp, nil
}
// WallarmModeRead requests wallarm_mode info.
// API reference: https://apiconsole.eu1.wallarm.com
func (api *api) WallarmModeRead(clientID int) (*WallarmModeResponse, error) {
url := fmt.Sprintf("/v2/client/%d/rules/wallarm_mode", clientID)
rawResp, err := api.makeRequest("GET", url, "wallarm_mode", nil)
if err != nil {
return nil, err
}
var resp WallarmModeResponse
if err = json.Unmarshal(rawResp, &resp); err != nil {
return nil, err
}
return &resp, nil
}