forked from esurdam/go-sophos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcron.go
177 lines (141 loc) · 5.75 KB
/
cron.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
package objects
import (
"fmt"
"github.com/esurdam/go-sophos"
)
// Cron is a generated struct representing the Sophos Cron Endpoint
// GET /api/nodes/cron
type Cron struct {
CronAt CronAt `json:"cron_at"`
CronGroup CronGroup `json:"cron_group"`
}
var _ sophos.Endpoint = &Cron{}
var defsCron = map[string]sophos.RestObject{
"CronAt": &CronAt{},
"CronGroup": &CronGroup{},
}
// RestObjects implements the sophos.Node interface and returns a map of Cron's Objects
func (Cron) RestObjects() map[string]sophos.RestObject { return defsCron }
// GetPath implements sophos.RestGetter
func (*Cron) GetPath() string { return "/api/nodes/cron" }
// RefRequired implements sophos.RestGetter
func (*Cron) RefRequired() (string, bool) { return "", false }
var defCron = &sophos.Definition{Description: "cron", Name: "cron", Link: "/api/definitions/cron"}
// Definition returns the /api/definitions struct of Cron
func (Cron) Definition() sophos.Definition { return *defCron }
// ApiRoutes returns all known Cron Paths
func (Cron) ApiRoutes() []string {
return []string{
"/api/objects/cron/at/",
"/api/objects/cron/at/{ref}",
"/api/objects/cron/at/{ref}/usedby",
"/api/objects/cron/group/",
"/api/objects/cron/group/{ref}",
"/api/objects/cron/group/{ref}/usedby",
}
}
// References returns the Cron's references. These strings serve no purpose other than to demonstrate which
// Reference keys are used for this Endpoint
func (Cron) References() []string {
return []string{
"REF_CronAt",
"REF_CronGroup",
}
}
// CronAts is an Sophos Endpoint subType and implements sophos.RestObject
type CronAts []CronAt
// CronAt represents a UTM scheduled job
type CronAt struct {
Locked string `json:"_locked"`
ObjectType string `json:"_type"`
Reference string `json:"_ref"`
Command string `json:"command"`
Comment string `json:"comment"`
// Date description: (DATE)
Date string `json:"date"`
Name string `json:"name"`
// Time description: (TIME)
Time string `json:"time"`
}
var _ sophos.RestGetter = &CronAt{}
// GetPath implements sophos.RestObject and returns the CronAts GET path
// Returns all available cron/at objects
func (*CronAts) GetPath() string { return "/api/objects/cron/at/" }
// RefRequired implements sophos.RestObject
func (*CronAts) RefRequired() (string, bool) { return "", false }
// GetPath implements sophos.RestObject and returns the CronAts GET path
// Returns all available at types
func (c *CronAt) GetPath() string { return fmt.Sprintf("/api/objects/cron/at/%s", c.Reference) }
// RefRequired implements sophos.RestObject
func (c *CronAt) RefRequired() (string, bool) { return c.Reference, true }
// DeletePath implements sophos.RestObject and returns the CronAt DELETE path
// Creates or updates the complete object at
func (*CronAt) DeletePath(ref string) string {
return fmt.Sprintf("/api/objects/cron/at/%s", ref)
}
// PatchPath implements sophos.RestObject and returns the CronAt PATCH path
// Changes to parts of the object at types
func (*CronAt) PatchPath(ref string) string {
return fmt.Sprintf("/api/objects/cron/at/%s", ref)
}
// PostPath implements sophos.RestObject and returns the CronAt POST path
// Create a new cron/at object
func (*CronAt) PostPath() string {
return "/api/objects/cron/at/"
}
// PutPath implements sophos.RestObject and returns the CronAt PUT path
// Creates or updates the complete object at
func (*CronAt) PutPath(ref string) string {
return fmt.Sprintf("/api/objects/cron/at/%s", ref)
}
// UsedByPath implements sophos.RestObject
// Returns the objects and the nodes that use the object with the given ref
func (*CronAt) UsedByPath(ref string) string {
return fmt.Sprintf("/api/objects/cron/at/%s/usedby", ref)
}
// CronGroups is an Sophos Endpoint subType and implements sophos.RestObject
type CronGroups []CronGroup
// CronGroup represents a UTM group
type CronGroup struct {
Locked string `json:"_locked"`
ObjectType string `json:"_type"`
Reference string `json:"_ref"`
Comment string `json:"comment"`
Name string `json:"name"`
}
var _ sophos.RestGetter = &CronGroup{}
// GetPath implements sophos.RestObject and returns the CronGroups GET path
// Returns all available cron/group objects
func (*CronGroups) GetPath() string { return "/api/objects/cron/group/" }
// RefRequired implements sophos.RestObject
func (*CronGroups) RefRequired() (string, bool) { return "", false }
// GetPath implements sophos.RestObject and returns the CronGroups GET path
// Returns all available group types
func (c *CronGroup) GetPath() string { return fmt.Sprintf("/api/objects/cron/group/%s", c.Reference) }
// RefRequired implements sophos.RestObject
func (c *CronGroup) RefRequired() (string, bool) { return c.Reference, true }
// DeletePath implements sophos.RestObject and returns the CronGroup DELETE path
// Creates or updates the complete object group
func (*CronGroup) DeletePath(ref string) string {
return fmt.Sprintf("/api/objects/cron/group/%s", ref)
}
// PatchPath implements sophos.RestObject and returns the CronGroup PATCH path
// Changes to parts of the object group types
func (*CronGroup) PatchPath(ref string) string {
return fmt.Sprintf("/api/objects/cron/group/%s", ref)
}
// PostPath implements sophos.RestObject and returns the CronGroup POST path
// Create a new cron/group object
func (*CronGroup) PostPath() string {
return "/api/objects/cron/group/"
}
// PutPath implements sophos.RestObject and returns the CronGroup PUT path
// Creates or updates the complete object group
func (*CronGroup) PutPath(ref string) string {
return fmt.Sprintf("/api/objects/cron/group/%s", ref)
}
// UsedByPath implements sophos.RestObject
// Returns the objects and the nodes that use the object with the given ref
func (*CronGroup) UsedByPath(ref string) string {
return fmt.Sprintf("/api/objects/cron/group/%s/usedby", ref)
}