forked from esurdam/go-sophos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
right.go
175 lines (138 loc) · 5.92 KB
/
right.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
package objects
import (
"fmt"
"github.com/esurdam/go-sophos"
)
// Right is a generated struct representing the Sophos Right Endpoint
// GET /api/nodes/right
type Right struct {
RightGroup RightGroup `json:"right_group"`
RightRight RightRight `json:"right_right"`
}
var _ sophos.Endpoint = &Right{}
var defsRight = map[string]sophos.RestObject{
"RightGroup": &RightGroup{},
"RightRight": &RightRight{},
}
// RestObjects implements the sophos.Node interface and returns a map of Right's Objects
func (Right) RestObjects() map[string]sophos.RestObject { return defsRight }
// GetPath implements sophos.RestGetter
func (*Right) GetPath() string { return "/api/nodes/right" }
// RefRequired implements sophos.RestGetter
func (*Right) RefRequired() (string, bool) { return "", false }
var defRight = &sophos.Definition{Description: "right", Name: "right", Link: "/api/definitions/right"}
// Definition returns the /api/definitions struct of Right
func (Right) Definition() sophos.Definition { return *defRight }
// ApiRoutes returns all known Right Paths
func (Right) ApiRoutes() []string {
return []string{
"/api/objects/right/group/",
"/api/objects/right/group/{ref}",
"/api/objects/right/group/{ref}/usedby",
"/api/objects/right/right/",
"/api/objects/right/right/{ref}",
"/api/objects/right/right/{ref}/usedby",
}
}
// References returns the Right's references. These strings serve no purpose other than to demonstrate which
// Reference keys are used for this Endpoint
func (Right) References() []string {
return []string{
"REF_RightGroup",
"REF_RightRight",
}
}
// RightGroups is an Sophos Endpoint subType and implements sophos.RestObject
type RightGroups []RightGroup
// RightGroup represents a UTM group
type RightGroup struct {
Locked string `json:"_locked"`
ObjectType string `json:"_type"`
Reference string `json:"_ref"`
Name string `json:"name"`
Comment string `json:"comment"`
}
var _ sophos.RestGetter = &RightGroup{}
// GetPath implements sophos.RestObject and returns the RightGroups GET path
// Returns all available right/group objects
func (*RightGroups) GetPath() string { return "/api/objects/right/group/" }
// RefRequired implements sophos.RestObject
func (*RightGroups) RefRequired() (string, bool) { return "", false }
// GetPath implements sophos.RestObject and returns the RightGroups GET path
// Returns all available group types
func (r *RightGroup) GetPath() string { return fmt.Sprintf("/api/objects/right/group/%s", r.Reference) }
// RefRequired implements sophos.RestObject
func (r *RightGroup) RefRequired() (string, bool) { return r.Reference, true }
// DeletePath implements sophos.RestObject and returns the RightGroup DELETE path
// Creates or updates the complete object group
func (*RightGroup) DeletePath(ref string) string {
return fmt.Sprintf("/api/objects/right/group/%s", ref)
}
// PatchPath implements sophos.RestObject and returns the RightGroup PATCH path
// Changes to parts of the object group types
func (*RightGroup) PatchPath(ref string) string {
return fmt.Sprintf("/api/objects/right/group/%s", ref)
}
// PostPath implements sophos.RestObject and returns the RightGroup POST path
// Create a new right/group object
func (*RightGroup) PostPath() string {
return "/api/objects/right/group/"
}
// PutPath implements sophos.RestObject and returns the RightGroup PUT path
// Creates or updates the complete object group
func (*RightGroup) PutPath(ref string) string {
return fmt.Sprintf("/api/objects/right/group/%s", ref)
}
// UsedByPath implements sophos.RestObject
// Returns the objects and the nodes that use the object with the given ref
func (*RightGroup) UsedByPath(ref string) string {
return fmt.Sprintf("/api/objects/right/group/%s/usedby", ref)
}
// RightRights is an Sophos Endpoint subType and implements sophos.RestObject
type RightRights []RightRight
// RightRight is a generated Sophos object
type RightRight struct {
Locked string `json:"_locked"`
Reference string `json:"_ref"`
ObjectType string `json:"_type"`
Comment string `json:"comment"`
Name string `json:"name"`
}
var _ sophos.RestGetter = &RightRight{}
// GetPath implements sophos.RestObject and returns the RightRights GET path
// Returns all available right/right objects
func (*RightRights) GetPath() string { return "/api/objects/right/right/" }
// RefRequired implements sophos.RestObject
func (*RightRights) RefRequired() (string, bool) { return "", false }
// GetPath implements sophos.RestObject and returns the RightRights GET path
// Returns all available right types
func (r *RightRight) GetPath() string { return fmt.Sprintf("/api/objects/right/right/%s", r.Reference) }
// RefRequired implements sophos.RestObject
func (r *RightRight) RefRequired() (string, bool) { return r.Reference, true }
// DeletePath implements sophos.RestObject and returns the RightRight DELETE path
// Creates or updates the complete object right
func (*RightRight) DeletePath(ref string) string {
return fmt.Sprintf("/api/objects/right/right/%s", ref)
}
// PatchPath implements sophos.RestObject and returns the RightRight PATCH path
// Changes to parts of the object right types
func (*RightRight) PatchPath(ref string) string {
return fmt.Sprintf("/api/objects/right/right/%s", ref)
}
// PostPath implements sophos.RestObject and returns the RightRight POST path
// Create a new right/right object
func (*RightRight) PostPath() string {
return "/api/objects/right/right/"
}
// PutPath implements sophos.RestObject and returns the RightRight PUT path
// Creates or updates the complete object right
func (*RightRight) PutPath(ref string) string {
return fmt.Sprintf("/api/objects/right/right/%s", ref)
}
// UsedByPath implements sophos.RestObject
// Returns the objects and the nodes that use the object with the given ref
func (*RightRight) UsedByPath(ref string) string {
return fmt.Sprintf("/api/objects/right/right/%s/usedby", ref)
}
// GetType implements sophos.Object
func (r *RightRight) GetType() string { return r.ObjectType }