-
Notifications
You must be signed in to change notification settings - Fork 4
/
scheduler.go
286 lines (237 loc) · 10.9 KB
/
scheduler.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
package objects
// THIS FILE IS AUTO GENERATED BY bin/gen.go! DO NOT EDIT!
import (
"fmt"
"github.com/esurdam/go-sophos"
)
// Scheduler is a generated struct representing the Sophos Scheduler Endpoint
// GET /api/nodes/scheduler
type Scheduler struct {
SchedulerGroup SchedulerGroup `json:"scheduler_group"`
SchedulerLoadbalance SchedulerLoadbalance `json:"scheduler_loadbalance"`
SchedulerRule SchedulerRule `json:"scheduler_rule"`
}
var _ sophos.Endpoint = &Scheduler{}
var defsScheduler = map[string]sophos.RestObject{
"SchedulerGroup": &SchedulerGroup{},
"SchedulerLoadbalance": &SchedulerLoadbalance{},
"SchedulerRule": &SchedulerRule{},
}
// RestObjects implements the sophos.Node interface and returns a map of Scheduler's Objects
func (Scheduler) RestObjects() map[string]sophos.RestObject { return defsScheduler }
// GetPath implements sophos.RestGetter
func (*Scheduler) GetPath() string { return "/api/nodes/scheduler" }
// RefRequired implements sophos.RestGetter
func (*Scheduler) RefRequired() (string, bool) { return "", false }
var defScheduler = &sophos.Definition{Description: "scheduler", Name: "scheduler", Link: "/api/definitions/scheduler"}
// Definition returns the /api/definitions struct of Scheduler
func (Scheduler) Definition() sophos.Definition { return *defScheduler }
// ApiRoutes returns all known Scheduler Paths
func (Scheduler) ApiRoutes() []string {
return []string{
"/api/objects/scheduler/group/",
"/api/objects/scheduler/group/{ref}",
"/api/objects/scheduler/group/{ref}/usedby",
"/api/objects/scheduler/loadbalance/",
"/api/objects/scheduler/loadbalance/{ref}",
"/api/objects/scheduler/loadbalance/{ref}/usedby",
"/api/objects/scheduler/rule/",
"/api/objects/scheduler/rule/{ref}",
"/api/objects/scheduler/rule/{ref}/usedby",
}
}
// References returns the Scheduler's references. These strings serve no purpose other than to demonstrate which
// Reference keys are used for this Endpoint
func (Scheduler) References() []string {
return []string{
"REF_SchedulerGroup",
"REF_SchedulerLoadbalance",
"REF_SchedulerRule",
}
}
// SchedulerGroups is an Sophos Endpoint subType and implements sophos.RestObject
type SchedulerGroups []SchedulerGroup
// SchedulerGroup represents a UTM group
type SchedulerGroup struct {
Locked string `json:"_locked"`
ObjectType string `json:"_type"`
Reference string `json:"_ref"`
Comment string `json:"comment"`
Name string `json:"name"`
}
var _ sophos.RestGetter = &SchedulerGroup{}
// GetPath implements sophos.RestObject and returns the SchedulerGroups GET path
// Returns all available scheduler/group objects
func (*SchedulerGroups) GetPath() string { return "/api/objects/scheduler/group/" }
// RefRequired implements sophos.RestObject
func (*SchedulerGroups) RefRequired() (string, bool) { return "", false }
// GetPath implements sophos.RestObject and returns the SchedulerGroups GET path
// Returns all available group types
func (s *SchedulerGroup) GetPath() string {
return fmt.Sprintf("/api/objects/scheduler/group/%s", s.Reference)
}
// RefRequired implements sophos.RestObject
func (s *SchedulerGroup) RefRequired() (string, bool) { return s.Reference, true }
// DeletePath implements sophos.RestObject and returns the SchedulerGroup DELETE path
// Creates or updates the complete object group
func (*SchedulerGroup) DeletePath(ref string) string {
return fmt.Sprintf("/api/objects/scheduler/group/%s", ref)
}
// PatchPath implements sophos.RestObject and returns the SchedulerGroup PATCH path
// Changes to parts of the object group types
func (*SchedulerGroup) PatchPath(ref string) string {
return fmt.Sprintf("/api/objects/scheduler/group/%s", ref)
}
// PostPath implements sophos.RestObject and returns the SchedulerGroup POST path
// Create a new scheduler/group object
func (*SchedulerGroup) PostPath() string {
return "/api/objects/scheduler/group/"
}
// PutPath implements sophos.RestObject and returns the SchedulerGroup PUT path
// Creates or updates the complete object group
func (*SchedulerGroup) PutPath(ref string) string {
return fmt.Sprintf("/api/objects/scheduler/group/%s", ref)
}
// UsedByPath implements sophos.RestObject
// Returns the objects and the nodes that use the object with the given ref
func (*SchedulerGroup) UsedByPath(ref string) string {
return fmt.Sprintf("/api/objects/scheduler/group/%s/usedby", ref)
}
// SchedulerLoadbalances is an Sophos Endpoint subType and implements sophos.RestObject
type SchedulerLoadbalances []SchedulerLoadbalance
// SchedulerLoadbalance represents a UTM loadbalance scheduler
type SchedulerLoadbalance struct {
Locked string `json:"_locked"`
ObjectType string `json:"_type"`
Reference string `json:"_ref"`
// Algorithm can be one of: []string{"roundrobin", "hash", "weight", "least"}
// Algorithm default value is "roundrobin"
Algorithm string `json:"algorithm"`
// CheckData default value is ""
CheckData string `json:"check_data"`
CheckHosts []string `json:"check_hosts"`
CheckInterval int `json:"check_interval"`
CheckPort int `json:"check_port"`
CheckTimeout int `json:"check_timeout"`
// CheckType can be one of: []string{"none", "auto", "icmp", "udp", "tcp", "http", "https"}
// CheckType default value is "auto"
CheckType string `json:"check_type"`
Comment string `json:"comment"`
Name string `json:"name"`
// Persistence default value is true
Persistence bool `json:"persistence"`
// PersistenceHash can be one of: []string{"src", "dst", "src-dst"}
// PersistenceHash default value is "src"
PersistenceHash string `json:"persistence_hash"`
PersistenceSize int `json:"persistence_size"`
PersistenceTime int `json:"persistence_time"`
// Weight description: (HASH)
Weight interface{} `json:"weight"`
}
var _ sophos.RestGetter = &SchedulerLoadbalance{}
// GetPath implements sophos.RestObject and returns the SchedulerLoadbalances GET path
// Returns all available scheduler/loadbalance objects
func (*SchedulerLoadbalances) GetPath() string { return "/api/objects/scheduler/loadbalance/" }
// RefRequired implements sophos.RestObject
func (*SchedulerLoadbalances) RefRequired() (string, bool) { return "", false }
// GetPath implements sophos.RestObject and returns the SchedulerLoadbalances GET path
// Returns all available loadbalance types
func (s *SchedulerLoadbalance) GetPath() string {
return fmt.Sprintf("/api/objects/scheduler/loadbalance/%s", s.Reference)
}
// RefRequired implements sophos.RestObject
func (s *SchedulerLoadbalance) RefRequired() (string, bool) { return s.Reference, true }
// DeletePath implements sophos.RestObject and returns the SchedulerLoadbalance DELETE path
// Creates or updates the complete object loadbalance
func (*SchedulerLoadbalance) DeletePath(ref string) string {
return fmt.Sprintf("/api/objects/scheduler/loadbalance/%s", ref)
}
// PatchPath implements sophos.RestObject and returns the SchedulerLoadbalance PATCH path
// Changes to parts of the object loadbalance types
func (*SchedulerLoadbalance) PatchPath(ref string) string {
return fmt.Sprintf("/api/objects/scheduler/loadbalance/%s", ref)
}
// PostPath implements sophos.RestObject and returns the SchedulerLoadbalance POST path
// Create a new scheduler/loadbalance object
func (*SchedulerLoadbalance) PostPath() string {
return "/api/objects/scheduler/loadbalance/"
}
// PutPath implements sophos.RestObject and returns the SchedulerLoadbalance PUT path
// Creates or updates the complete object loadbalance
func (*SchedulerLoadbalance) PutPath(ref string) string {
return fmt.Sprintf("/api/objects/scheduler/loadbalance/%s", ref)
}
// UsedByPath implements sophos.RestObject
// Returns the objects and the nodes that use the object with the given ref
func (*SchedulerLoadbalance) UsedByPath(ref string) string {
return fmt.Sprintf("/api/objects/scheduler/loadbalance/%s/usedby", ref)
}
// SchedulerRules is an Sophos Endpoint subType and implements sophos.RestObject
type SchedulerRules []SchedulerRule
// SchedulerRule represents a UTM multipath rule
type SchedulerRule struct {
Locked string `json:"_locked"`
ObjectType string `json:"_type"`
Reference string `json:"_ref"`
Comment string `json:"comment"`
// Destination description: REF(network/*)
Destination string `json:"destination"`
// Interface description: REF(interface/*)
// Interface default value is ""
Interface string `json:"interface"`
// InterfaceGroup description: REF(interface/group)
// InterfaceGroup default value is "REF_UplinkInterfaces"
InterfaceGroup string `json:"interface_group"`
Name string `json:"name"`
// Persistence default value is true
Persistence bool `json:"persistence"`
// PersistenceHash can be one of: []string{"src", "dst", "src-dst"}
// PersistenceHash default value is ""
PersistenceHash string `json:"persistence_hash"`
// Service description: REF(service/*)
Service string `json:"service"`
// SkipOnError default value is true
SkipOnError bool `json:"skip_on_error"`
// Source description: REF(network/*)
Source string `json:"source"`
// Status default value is false
Status bool `json:"status"`
}
var _ sophos.RestGetter = &SchedulerRule{}
// GetPath implements sophos.RestObject and returns the SchedulerRules GET path
// Returns all available scheduler/rule objects
func (*SchedulerRules) GetPath() string { return "/api/objects/scheduler/rule/" }
// RefRequired implements sophos.RestObject
func (*SchedulerRules) RefRequired() (string, bool) { return "", false }
// GetPath implements sophos.RestObject and returns the SchedulerRules GET path
// Returns all available rule types
func (s *SchedulerRule) GetPath() string {
return fmt.Sprintf("/api/objects/scheduler/rule/%s", s.Reference)
}
// RefRequired implements sophos.RestObject
func (s *SchedulerRule) RefRequired() (string, bool) { return s.Reference, true }
// DeletePath implements sophos.RestObject and returns the SchedulerRule DELETE path
// Creates or updates the complete object rule
func (*SchedulerRule) DeletePath(ref string) string {
return fmt.Sprintf("/api/objects/scheduler/rule/%s", ref)
}
// PatchPath implements sophos.RestObject and returns the SchedulerRule PATCH path
// Changes to parts of the object rule types
func (*SchedulerRule) PatchPath(ref string) string {
return fmt.Sprintf("/api/objects/scheduler/rule/%s", ref)
}
// PostPath implements sophos.RestObject and returns the SchedulerRule POST path
// Create a new scheduler/rule object
func (*SchedulerRule) PostPath() string {
return "/api/objects/scheduler/rule/"
}
// PutPath implements sophos.RestObject and returns the SchedulerRule PUT path
// Creates or updates the complete object rule
func (*SchedulerRule) PutPath(ref string) string {
return fmt.Sprintf("/api/objects/scheduler/rule/%s", ref)
}
// UsedByPath implements sophos.RestObject
// Returns the objects and the nodes that use the object with the given ref
func (*SchedulerRule) UsedByPath(ref string) string {
return fmt.Sprintf("/api/objects/scheduler/rule/%s/usedby", ref)
}