-
Notifications
You must be signed in to change notification settings - Fork 4
/
time.go
253 lines (204 loc) · 8.76 KB
/
time.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
package objects
// THIS FILE IS AUTO GENERATED BY bin/gen.go! DO NOT EDIT!
import (
"fmt"
"github.com/esurdam/go-sophos"
)
// Time is a generated struct representing the Sophos Time Endpoint
// GET /api/nodes/time
type Time struct {
TimeGroup TimeGroup `json:"time_group"`
TimeRecurring TimeRecurring `json:"time_recurring"`
TimeSingle TimeSingle `json:"time_single"`
}
var _ sophos.Endpoint = &Time{}
var defsTime = map[string]sophos.RestObject{
"TimeGroup": &TimeGroup{},
"TimeRecurring": &TimeRecurring{},
"TimeSingle": &TimeSingle{},
}
// RestObjects implements the sophos.Node interface and returns a map of Time's Objects
func (Time) RestObjects() map[string]sophos.RestObject { return defsTime }
// GetPath implements sophos.RestGetter
func (*Time) GetPath() string { return "/api/nodes/time" }
// RefRequired implements sophos.RestGetter
func (*Time) RefRequired() (string, bool) { return "", false }
var defTime = &sophos.Definition{Description: "time", Name: "time", Link: "/api/definitions/time"}
// Definition returns the /api/definitions struct of Time
func (Time) Definition() sophos.Definition { return *defTime }
// ApiRoutes returns all known Time Paths
func (Time) ApiRoutes() []string {
return []string{
"/api/objects/time/group/",
"/api/objects/time/group/{ref}",
"/api/objects/time/group/{ref}/usedby",
"/api/objects/time/recurring/",
"/api/objects/time/recurring/{ref}",
"/api/objects/time/recurring/{ref}/usedby",
"/api/objects/time/single/",
"/api/objects/time/single/{ref}",
"/api/objects/time/single/{ref}/usedby",
}
}
// References returns the Time's references. These strings serve no purpose other than to demonstrate which
// Reference keys are used for this Endpoint
func (Time) References() []string {
return []string{
"REF_TimeGroup",
"REF_TimeRecurring",
"REF_TimeSingle",
}
}
// TimeGroups is an Sophos Endpoint subType and implements sophos.RestObject
type TimeGroups []TimeGroup
// TimeGroup represents a UTM group
type TimeGroup struct {
Locked string `json:"_locked"`
ObjectType string `json:"_type"`
Reference string `json:"_ref"`
Comment string `json:"comment"`
Name string `json:"name"`
}
var _ sophos.RestGetter = &TimeGroup{}
// GetPath implements sophos.RestObject and returns the TimeGroups GET path
// Returns all available time/group objects
func (*TimeGroups) GetPath() string { return "/api/objects/time/group/" }
// RefRequired implements sophos.RestObject
func (*TimeGroups) RefRequired() (string, bool) { return "", false }
// GetPath implements sophos.RestObject and returns the TimeGroups GET path
// Returns all available group types
func (t *TimeGroup) GetPath() string { return fmt.Sprintf("/api/objects/time/group/%s", t.Reference) }
// RefRequired implements sophos.RestObject
func (t *TimeGroup) RefRequired() (string, bool) { return t.Reference, true }
// DeletePath implements sophos.RestObject and returns the TimeGroup DELETE path
// Creates or updates the complete object group
func (*TimeGroup) DeletePath(ref string) string {
return fmt.Sprintf("/api/objects/time/group/%s", ref)
}
// PatchPath implements sophos.RestObject and returns the TimeGroup PATCH path
// Changes to parts of the object group types
func (*TimeGroup) PatchPath(ref string) string {
return fmt.Sprintf("/api/objects/time/group/%s", ref)
}
// PostPath implements sophos.RestObject and returns the TimeGroup POST path
// Create a new time/group object
func (*TimeGroup) PostPath() string {
return "/api/objects/time/group/"
}
// PutPath implements sophos.RestObject and returns the TimeGroup PUT path
// Creates or updates the complete object group
func (*TimeGroup) PutPath(ref string) string {
return fmt.Sprintf("/api/objects/time/group/%s", ref)
}
// UsedByPath implements sophos.RestObject
// Returns the objects and the nodes that use the object with the given ref
func (*TimeGroup) UsedByPath(ref string) string {
return fmt.Sprintf("/api/objects/time/group/%s/usedby", ref)
}
// TimeRecurrings is an Sophos Endpoint subType and implements sophos.RestObject
type TimeRecurrings []TimeRecurring
// TimeRecurring represents a UTM recurring time period
type TimeRecurring struct {
Locked string `json:"_locked"`
ObjectType string `json:"_type"`
Reference string `json:"_ref"`
Comment string `json:"comment"`
// EndTime description: (TIME)
EndTime string `json:"end_time"`
Name string `json:"name"`
// StartTime description: (TIME)
StartTime string `json:"start_time"`
Weekdays []string `json:"weekdays"`
}
var _ sophos.RestGetter = &TimeRecurring{}
// GetPath implements sophos.RestObject and returns the TimeRecurrings GET path
// Returns all available time/recurring objects
func (*TimeRecurrings) GetPath() string { return "/api/objects/time/recurring/" }
// RefRequired implements sophos.RestObject
func (*TimeRecurrings) RefRequired() (string, bool) { return "", false }
// GetPath implements sophos.RestObject and returns the TimeRecurrings GET path
// Returns all available recurring types
func (t *TimeRecurring) GetPath() string {
return fmt.Sprintf("/api/objects/time/recurring/%s", t.Reference)
}
// RefRequired implements sophos.RestObject
func (t *TimeRecurring) RefRequired() (string, bool) { return t.Reference, true }
// DeletePath implements sophos.RestObject and returns the TimeRecurring DELETE path
// Creates or updates the complete object recurring
func (*TimeRecurring) DeletePath(ref string) string {
return fmt.Sprintf("/api/objects/time/recurring/%s", ref)
}
// PatchPath implements sophos.RestObject and returns the TimeRecurring PATCH path
// Changes to parts of the object recurring types
func (*TimeRecurring) PatchPath(ref string) string {
return fmt.Sprintf("/api/objects/time/recurring/%s", ref)
}
// PostPath implements sophos.RestObject and returns the TimeRecurring POST path
// Create a new time/recurring object
func (*TimeRecurring) PostPath() string {
return "/api/objects/time/recurring/"
}
// PutPath implements sophos.RestObject and returns the TimeRecurring PUT path
// Creates or updates the complete object recurring
func (*TimeRecurring) PutPath(ref string) string {
return fmt.Sprintf("/api/objects/time/recurring/%s", ref)
}
// UsedByPath implements sophos.RestObject
// Returns the objects and the nodes that use the object with the given ref
func (*TimeRecurring) UsedByPath(ref string) string {
return fmt.Sprintf("/api/objects/time/recurring/%s/usedby", ref)
}
// TimeSingles is an Sophos Endpoint subType and implements sophos.RestObject
type TimeSingles []TimeSingle
// TimeSingle represents a UTM single time period
type TimeSingle struct {
Locked string `json:"_locked"`
ObjectType string `json:"_type"`
Reference string `json:"_ref"`
Comment string `json:"comment"`
// EndDate description: (DATE)
EndDate string `json:"end_date"`
// EndTime description: (TIME)
EndTime string `json:"end_time"`
Name string `json:"name"`
// StartDate description: (DATE)
StartDate string `json:"start_date"`
// StartTime description: (TIME)
StartTime string `json:"start_time"`
}
var _ sophos.RestGetter = &TimeSingle{}
// GetPath implements sophos.RestObject and returns the TimeSingles GET path
// Returns all available time/single objects
func (*TimeSingles) GetPath() string { return "/api/objects/time/single/" }
// RefRequired implements sophos.RestObject
func (*TimeSingles) RefRequired() (string, bool) { return "", false }
// GetPath implements sophos.RestObject and returns the TimeSingles GET path
// Returns all available single types
func (t *TimeSingle) GetPath() string { return fmt.Sprintf("/api/objects/time/single/%s", t.Reference) }
// RefRequired implements sophos.RestObject
func (t *TimeSingle) RefRequired() (string, bool) { return t.Reference, true }
// DeletePath implements sophos.RestObject and returns the TimeSingle DELETE path
// Creates or updates the complete object single
func (*TimeSingle) DeletePath(ref string) string {
return fmt.Sprintf("/api/objects/time/single/%s", ref)
}
// PatchPath implements sophos.RestObject and returns the TimeSingle PATCH path
// Changes to parts of the object single types
func (*TimeSingle) PatchPath(ref string) string {
return fmt.Sprintf("/api/objects/time/single/%s", ref)
}
// PostPath implements sophos.RestObject and returns the TimeSingle POST path
// Create a new time/single object
func (*TimeSingle) PostPath() string {
return "/api/objects/time/single/"
}
// PutPath implements sophos.RestObject and returns the TimeSingle PUT path
// Creates or updates the complete object single
func (*TimeSingle) PutPath(ref string) string {
return fmt.Sprintf("/api/objects/time/single/%s", ref)
}
// UsedByPath implements sophos.RestObject
// Returns the objects and the nodes that use the object with the given ref
func (*TimeSingle) UsedByPath(ref string) string {
return fmt.Sprintf("/api/objects/time/single/%s/usedby", ref)
}