-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrules_settings.go
72 lines (63 loc) · 2.57 KB
/
rules_settings.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package wallarm
import (
"encoding/json"
"fmt"
)
type (
RuleSettings interface {
RulesSettingsRead(clientID int) (*RulesSettingsResponse, error)
RulesSettingsUpdate(params *RuleSettingsParams, clientID int) (*RulesSettingsResponse, error)
}
RulesSettingsResponse struct {
Status int `json:"status"`
Body *RulesSettingsResponseBody `json:"body"`
}
RulesSettingsResponseBody struct {
ClientId int `json:"clientid"`
*RuleSettingsParams
}
RuleSettingsParams struct {
MinLomFormat *int `json:"min_lom_format,omitempty"`
MaxLomFormat *int `json:"max_lom_format,omitempty"`
MaxLomSize *int `json:"max_lom_size,omitempty"`
LomDisabled *bool `json:"lom_disabled,omitempty"`
LomCompilationDelay *int `json:"lom_compilation_delay,omitempty"`
RulesSnapshotEnabled *bool `json:"rules_snapshot_enabled,omitempty"`
RulesSnapshotMaxCount *int `json:"rules_snapshot_max_count,omitempty"`
RulesManipulationLocked *bool `json:"rules_manipulation_locked,omitempty"`
HeavyLom *bool `json:"heavy_lom,omitempty"`
DataInS3 *bool `json:"data_in_s3,omitempty"`
ParametersCountWeight *int `json:"parameters_count_weight,omitempty"`
PathVariativityWeight *int `json:"path_variativity_weight,omitempty"`
PiiWeight *int `json:"pii_weight,omitempty"`
RequestContentWeight *int `json:"request_content_weight,omitempty"`
OpenVulnsWeight *int `json:"open_vulns_weight,omitempty"`
SerializedDataWeight *int `json:"serialized_data_weight,omitempty"`
RiskScoreAlgo *string `json:"risk_score_algo,omitempty"`
PiiFallback *bool `json:"pii_fallback,omitempty"`
}
)
func (api *api) RulesSettingsRead(clientID int) (*RulesSettingsResponse, error) {
uri := fmt.Sprintf("/v2/client/%d/rules/settings", clientID)
rawResponse, err := api.makeRequest("GET", uri, "rules_settings", nil)
if err != nil {
return nil, err
}
var response RulesSettingsResponse
if err = json.Unmarshal(rawResponse, &response); err != nil {
return nil, err
}
return &response, nil
}
func (api *api) RulesSettingsUpdate(params *RuleSettingsParams, clientID int) (*RulesSettingsResponse, error) {
uri := fmt.Sprintf("/v2/client/%d/rules/settings", clientID)
rawResponse, err := api.makeRequest("PUT", uri, "rules_settings", params)
if err != nil {
return nil, err
}
var response RulesSettingsResponse
if err = json.Unmarshal(rawResponse, &response); err != nil {
return nil, err
}
return &response, nil
}