forked from esurdam/go-sophos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverride.go
182 lines (146 loc) · 6.36 KB
/
override.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
package objects
import (
"fmt"
"github.com/esurdam/go-sophos"
)
// Override is a generated struct representing the Sophos Override Endpoint
// GET /api/nodes/override
type Override struct {
OverrideGroup OverrideGroup `json:"override_group"`
OverrideObjref OverrideObjref `json:"override_objref"`
}
var _ sophos.Endpoint = &Override{}
var defsOverride = map[string]sophos.RestObject{
"OverrideGroup": &OverrideGroup{},
"OverrideObjref": &OverrideObjref{},
}
// RestObjects implements the sophos.Node interface and returns a map of Override's Objects
func (Override) RestObjects() map[string]sophos.RestObject { return defsOverride }
// GetPath implements sophos.RestGetter
func (*Override) GetPath() string { return "/api/nodes/override" }
// RefRequired implements sophos.RestGetter
func (*Override) RefRequired() (string, bool) { return "", false }
var defOverride = &sophos.Definition{Description: "override", Name: "override", Link: "/api/definitions/override"}
// Definition returns the /api/definitions struct of Override
func (Override) Definition() sophos.Definition { return *defOverride }
// ApiRoutes returns all known Override Paths
func (Override) ApiRoutes() []string {
return []string{
"/api/objects/override/group/",
"/api/objects/override/group/{ref}",
"/api/objects/override/group/{ref}/usedby",
"/api/objects/override/objref/",
"/api/objects/override/objref/{ref}",
"/api/objects/override/objref/{ref}/usedby",
}
}
// References returns the Override's references. These strings serve no purpose other than to demonstrate which
// Reference keys are used for this Endpoint
func (Override) References() []string {
return []string{
"REF_OverrideGroup",
"REF_OverrideObjref",
}
}
// OverrideGroups is an Sophos Endpoint subType and implements sophos.RestObject
type OverrideGroups []OverrideGroup
// OverrideGroup represents a UTM group
type OverrideGroup struct {
Locked string `json:"_locked"`
ObjectType string `json:"_type"`
Reference string `json:"_ref"`
Comment string `json:"comment"`
Name string `json:"name"`
}
var _ sophos.RestGetter = &OverrideGroup{}
// GetPath implements sophos.RestObject and returns the OverrideGroups GET path
// Returns all available override/group objects
func (*OverrideGroups) GetPath() string { return "/api/objects/override/group/" }
// RefRequired implements sophos.RestObject
func (*OverrideGroups) RefRequired() (string, bool) { return "", false }
// GetPath implements sophos.RestObject and returns the OverrideGroups GET path
// Returns all available group types
func (o *OverrideGroup) GetPath() string {
return fmt.Sprintf("/api/objects/override/group/%s", o.Reference)
}
// RefRequired implements sophos.RestObject
func (o *OverrideGroup) RefRequired() (string, bool) { return o.Reference, true }
// DeletePath implements sophos.RestObject and returns the OverrideGroup DELETE path
// Creates or updates the complete object group
func (*OverrideGroup) DeletePath(ref string) string {
return fmt.Sprintf("/api/objects/override/group/%s", ref)
}
// PatchPath implements sophos.RestObject and returns the OverrideGroup PATCH path
// Changes to parts of the object group types
func (*OverrideGroup) PatchPath(ref string) string {
return fmt.Sprintf("/api/objects/override/group/%s", ref)
}
// PostPath implements sophos.RestObject and returns the OverrideGroup POST path
// Create a new override/group object
func (*OverrideGroup) PostPath() string {
return "/api/objects/override/group/"
}
// PutPath implements sophos.RestObject and returns the OverrideGroup PUT path
// Creates or updates the complete object group
func (*OverrideGroup) PutPath(ref string) string {
return fmt.Sprintf("/api/objects/override/group/%s", ref)
}
// UsedByPath implements sophos.RestObject
// Returns the objects and the nodes that use the object with the given ref
func (*OverrideGroup) UsedByPath(ref string) string {
return fmt.Sprintf("/api/objects/override/group/%s/usedby", ref)
}
// OverrideObjrefs is an Sophos Endpoint subType and implements sophos.RestObject
type OverrideObjrefs []OverrideObjref
// OverrideObjref represents a UTM monitoring action
type OverrideObjref struct {
Locked string `json:"_locked"`
ObjectType string `json:"_type"`
Reference string `json:"_ref"`
Name string `json:"name"`
// Ref description: REF(/*)
Ref string `json:"ref"`
Value string `json:"value"`
Attr string `json:"attr"`
Comment string `json:"comment"`
// Condition description: REF(condition/*)
Condition string `json:"condition"`
}
var _ sophos.RestGetter = &OverrideObjref{}
// GetPath implements sophos.RestObject and returns the OverrideObjrefs GET path
// Returns all available override/objref objects
func (*OverrideObjrefs) GetPath() string { return "/api/objects/override/objref/" }
// RefRequired implements sophos.RestObject
func (*OverrideObjrefs) RefRequired() (string, bool) { return "", false }
// GetPath implements sophos.RestObject and returns the OverrideObjrefs GET path
// Returns all available objref types
func (o *OverrideObjref) GetPath() string {
return fmt.Sprintf("/api/objects/override/objref/%s", o.Reference)
}
// RefRequired implements sophos.RestObject
func (o *OverrideObjref) RefRequired() (string, bool) { return o.Reference, true }
// DeletePath implements sophos.RestObject and returns the OverrideObjref DELETE path
// Creates or updates the complete object objref
func (*OverrideObjref) DeletePath(ref string) string {
return fmt.Sprintf("/api/objects/override/objref/%s", ref)
}
// PatchPath implements sophos.RestObject and returns the OverrideObjref PATCH path
// Changes to parts of the object objref types
func (*OverrideObjref) PatchPath(ref string) string {
return fmt.Sprintf("/api/objects/override/objref/%s", ref)
}
// PostPath implements sophos.RestObject and returns the OverrideObjref POST path
// Create a new override/objref object
func (*OverrideObjref) PostPath() string {
return "/api/objects/override/objref/"
}
// PutPath implements sophos.RestObject and returns the OverrideObjref PUT path
// Creates or updates the complete object objref
func (*OverrideObjref) PutPath(ref string) string {
return fmt.Sprintf("/api/objects/override/objref/%s", ref)
}
// UsedByPath implements sophos.RestObject
// Returns the objects and the nodes that use the object with the given ref
func (*OverrideObjref) UsedByPath(ref string) string {
return fmt.Sprintf("/api/objects/override/objref/%s/usedby", ref)
}