-
Notifications
You must be signed in to change notification settings - Fork 1
/
zpa_lss_config_controller.go
198 lines (180 loc) · 9.04 KB
/
zpa_lss_config_controller.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
package lssconfigcontroller
import (
"fmt"
"net/http"
"strings"
"github.com/zscaler/zscaler-sdk-go/zpa/services/common"
)
const (
mgmtConfig = "/mgmtconfig/v2/admin/customers/"
mgmtConfigTypesAndFormats = "/mgmtconfig/v2/admin/"
lssConfigEndpoint = "/lssConfig"
)
type LSSResource struct {
LSSConfig *LSSConfig `json:"config"`
ID string `json:"id"`
ConnectorGroups []ConnectorGroups `json:"connectorGroups,omitempty"`
PolicyRule *PolicyRule `json:"policyRule,omitempty"`
PolicyRuleResource *PolicyRuleResource `json:"policyRuleResource,omitempty"`
}
type LSSConfig struct {
AuditMessage string `json:"auditMessage,omitempty"`
CreationTime string `json:"creationTime,omitempty"`
Description string `json:"description,omitempty"`
Enabled bool `json:"enabled,omitempty"`
Filter []string `json:"filter,omitempty"`
Format string `json:"format,omitempty"`
ID string `json:"id,omitempty"`
ModifiedBy string `json:"modifiedBy,omitempty"`
ModifiedTime string `json:"modifiedTime,omitempty"`
Name string `json:"name,omitempty"`
LSSHost string `json:"lssHost,omitempty"`
LSSPort string `json:"lssPort,omitempty"`
SourceLogType string `json:"sourceLogType,omitempty"`
UseTLS bool `json:"useTls,omitempty"`
}
type ConnectorGroups struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
}
type PolicyRuleResource struct {
Action string `json:"action,omitempty"`
ActionID string `json:"actionId,omitempty"`
BypassDefaultRule bool `json:"bypassDefaultRule,omitempty"`
CreationTime string `json:"creationTime,omitempty"`
CustomMsg string `json:"customMsg,omitempty"`
DefaultRule bool `json:"defaultRule,omitempty"`
Description string `json:"description,omitempty"`
ID string `json:"id,omitempty"`
IsolationDefaultRule bool `json:"isolationDefaultRule,omitempty"`
ModifiedBy string `json:"modifiedBy,omitempty"`
ModifiedTime string `json:"modifiedTime,omitempty"`
Name string `json:"name,omitempty"`
Operator string `json:"operator,omitempty"`
PolicySetID string `json:"policySetId,omitempty"`
PolicyType string `json:"policyType,omitempty"`
Priority string `json:"priority,omitempty"`
ReauthDefaultRule bool `json:"reauthDefaultRule,omitempty"`
ReauthIdleTimeout string `json:"reauthIdleTimeout,omitempty"`
ReauthTimeout string `json:"reauthTimeout,omitempty"`
RuleOrder string `json:"ruleOrder,omitempty"`
LssDefaultRule bool `json:"lssDefaultRule,omitempty"`
ZpnCbiProfileID string `json:"zpnCbiProfileId,omitempty"`
ZpnInspectionProfileID string `json:"zpnInspectionProfileId,omitempty"`
ZpnInspectionProfileName string `json:"zpnInspectionProfileName,omitempty"`
Conditions []PolicyRuleResourceConditions `json:"conditions,omitempty"`
}
type PolicyRule struct {
Action string `json:"action,omitempty"`
ActionID string `json:"actionId,omitempty"`
BypassDefaultRule bool `json:"bypassDefaultRule,omitempty"`
CreationTime string `json:"creationTime,omitempty"`
CustomMsg string `json:"customMsg,omitempty"`
DefaultRule bool `json:"defaultRule,omitempty"`
Description string `json:"description,omitempty"`
ID string `json:"id,omitempty"`
IsolationDefaultRule bool `json:"isolationDefaultRule,omitempty"`
ModifiedBy string `json:"modifiedBy,omitempty"`
ModifiedTime string `json:"modifiedTime,omitempty"`
Name string `json:"name,omitempty"`
Operator string `json:"operator,omitempty"`
PolicySetID string `json:"policySetId,omitempty"`
PolicyType string `json:"policyType,omitempty"`
Priority string `json:"priority,omitempty"`
ReauthDefaultRule bool `json:"reauthDefaultRule,omitempty"`
ReauthIdleTimeout string `json:"reauthIdleTimeout,omitempty"`
ReauthTimeout string `json:"reauthTimeout,omitempty"`
RuleOrder string `json:"ruleOrder,omitempty"`
LssDefaultRule bool `json:"lssDefaultRule,omitempty"`
ZpnCbiProfileID string `json:"zpnCbiProfileId,omitempty"`
ZpnInspectionProfileID string `json:"zpnInspectionProfileId,omitempty"`
ZpnInspectionProfileName string `json:"zpnInspectionProfileName,omitempty"`
Conditions []Conditions `json:"conditions,omitempty"`
}
type Conditions struct {
CreationTime string `json:"creationTime,omitempty"`
ID string `json:"id,omitempty"`
ModifiedBy string `json:"modifiedBy,omitempty"`
ModifiedTime string `json:"modifiedTime,omitempty"`
Negated bool `json:"negated"`
Operands *[]Operands `json:"operands,omitempty"`
Operator string `json:"operator,omitempty"`
}
type PolicyRuleResourceConditions struct {
CreationTime string `json:"creationTime,omitempty"`
ID string `json:"id,omitempty"`
ModifiedBy string `json:"modifiedBy,omitempty"`
ModifiedTime string `json:"modifiedTime,omitempty"`
Negated bool `json:"negated"`
Operands *[]PolicyRuleResourceOperands `json:"operands,omitempty"`
Operator string `json:"operator,omitempty"`
}
type PolicyRuleResourceOperands struct {
ObjectType string `json:"objectType,omitempty"`
Values []string `json:"values,omitempty"`
}
type Operands struct {
CreationTime string `json:"creationTime,omitempty"`
ID string `json:"id,omitempty"`
IdpID string `json:"idpId,omitempty"`
LHS string `json:"lhs,omitempty"`
ModifiedBy string `json:"modifiedBy,omitempty"`
ModifiedTime string `json:"modifiedTime,omitempty"`
Name string `json:"name,omitempty"`
ObjectType string `json:"objectType,omitempty"`
RHS string `json:"rhs,omitempty"`
}
func (service *Service) Get(lssID string) (*LSSResource, *http.Response, error) {
v := new(LSSResource)
relativeURL := fmt.Sprintf("%s/%s", mgmtConfig+service.Client.Config.CustomerID+lssConfigEndpoint, lssID)
resp, err := service.Client.NewRequestDo("GET", relativeURL, nil, nil, v)
if err != nil {
return nil, nil, err
}
return v, resp, nil
}
func (service *Service) GetByName(lssName string) (*LSSResource, *http.Response, error) {
relativeURL := mgmtConfig + service.Client.Config.CustomerID + lssConfigEndpoint
list, resp, err := common.GetAllPagesGeneric[LSSResource](service.Client, relativeURL, "")
if err != nil {
return nil, nil, err
}
for _, lss := range list {
if strings.EqualFold(lss.LSSConfig.Name, lssName) {
return &lss, resp, nil
}
}
return nil, resp, fmt.Errorf("no lss controller named '%s' was found", lssName)
}
func (service *Service) Create(lssConfig *LSSResource) (*LSSResource, *http.Response, error) {
v := new(LSSResource)
resp, err := service.Client.NewRequestDo("POST", mgmtConfig+service.Client.Config.CustomerID+lssConfigEndpoint, nil, lssConfig, &v)
if err != nil {
return nil, nil, err
}
return v, resp, nil
}
func (service *Service) Update(lssID string, lssConfig *LSSResource) (*http.Response, error) {
path := fmt.Sprintf("%s/%s", mgmtConfig+service.Client.Config.CustomerID+lssConfigEndpoint, lssID)
resp, err := service.Client.NewRequestDo("PUT", path, nil, lssConfig, nil)
if err != nil {
return nil, err
}
return resp, err
}
func (service *Service) Delete(lssID string) (*http.Response, error) {
path := fmt.Sprintf("%s/%s", mgmtConfig+service.Client.Config.CustomerID+lssConfigEndpoint, lssID)
resp, err := service.Client.NewRequestDo("DELETE", path, nil, nil, nil)
if err != nil {
return nil, err
}
return resp, err
}
func (service *Service) GetAll() ([]LSSResource, *http.Response, error) {
relativeURL := mgmtConfig + service.Client.Config.CustomerID + lssConfigEndpoint
list, resp, err := common.GetAllPagesGeneric[LSSResource](service.Client, relativeURL, "")
if err != nil {
return nil, nil, err
}
return list, resp, nil
}