@@ -6,14 +6,6 @@ import (
66 "io"
77)
88
9- // -------- Alert --------
10- type CustomNotification struct {
11- TitleTemplate string `json:"titleTemplate"`
12- UseNewTemplate bool `json:"useNewTemplate"`
13- PrependText string `json:"prependText,omitempty"`
14- AppendText string `json:"appendText,omitempty"`
15- }
16-
179type CloudAccountCredentials struct {
1810 AccountId string `json:"accountId"`
1911}
@@ -42,145 +34,6 @@ func CloudAccountToJSON(providerInfo *CloudAccount) io.Reader {
4234 return bytes .NewBuffer (payload )
4335}
4436
45- type SysdigCapture struct {
46- Name string `json:"name"`
47- Filters string `json:"filters,omitempty"`
48- Duration int `json:"duration"`
49- Type string `json:"type,omitempty"`
50- BucketName string `json:"bucketName"`
51- Folder string `json:"folder,omitempty"`
52- Enabled bool `json:"enabled"`
53- StorageID interface {} `json:"storageId,omitempty"`
54- }
55- type SegmentCondition struct {
56- Type string `json:"type"`
57- }
58-
59- type Criteria struct {
60- Text string `json:"text"`
61- Source string `json:"source"`
62- }
63-
64- type Monitor struct {
65- Metric string `json:"metric"`
66- StdDevFactor float64 `json:"stdDevFactor"`
67- }
68-
69- type alertWrapper struct {
70- Alert Alert `json:"alert"`
71- }
72-
73- type Alert struct {
74- ID int `json:"id,omitempty"`
75- Version int `json:"version,omitempty"`
76- Type string `json:"type"` // computed MANUAL
77- Name string `json:"name"`
78- Description string `json:"description"`
79- Enabled bool `json:"enabled"`
80- GroupName string `json:"groupName,omitempty"`
81- NotificationChannelIds []int `json:"notificationChannelIds"`
82- Filter string `json:"filter"`
83- Severity int `json:"severity"` // 6 == INFO, 4 == LOW, 2 == MEDIUM, 0 == HIGH // NOT USED
84- Timespan int `json:"timespan"` // computed 600000000
85- CustomNotification * CustomNotification `json:"customNotification"`
86- TeamID int `json:"teamId,omitempty"` // computed
87- AutoCreated bool `json:"autoCreated"`
88- SysdigCapture * SysdigCapture `json:"sysdigCapture"`
89- RateOfChange bool `json:"rateOfChange,omitempty"`
90- ReNotifyMinutes int `json:"reNotifyMinutes"`
91- ReNotify bool `json:"reNotify"`
92- Valid bool `json:"valid"`
93- SeverityLabel string `json:"severityLabel,omitempty"` // MEDIUM == MEDIUM, LOW == LOW, NONE == INFO, HIGH == HIGH
94- SegmentBy []string `json:"segmentBy"`
95- SegmentCondition * SegmentCondition `json:"segmentCondition"`
96- Criteria * Criteria `json:"criteria,omitempty"`
97- Monitor []* Monitor `json:"monitor,omitempty"`
98- Condition string `json:"condition"`
99- SeverityLevel int `json:"severityLevel,omitempty"` // 0 == MEDIUM, 2 == LOW, 4 == INFO, 6 == HIGH
100- }
101-
102- func (a * Alert ) ToJSON () io.Reader {
103- payload , _ := json .Marshal (alertWrapper {Alert : * a })
104- return bytes .NewBuffer (payload )
105- }
106-
107- func AlertFromJSON (body []byte ) Alert {
108- var result alertWrapper
109- _ = json .Unmarshal (body , & result )
110-
111- return result .Alert
112- }
113-
114- // -------- Team --------
115- type Team struct {
116- UserRoles []UserRoles `json:"userRoles"`
117- Description string `json:"description"`
118- Name string `json:"name"`
119- ID int `json:"id,omitempty"`
120- Version int `json:"version,omitempty"`
121- Origin string `json:"origin,omitempty"`
122- LastUpdated int64 `json:"lastUpdated,omitempty"`
123- EntryPoint EntryPoint `json:"entryPoint"`
124- Theme string `json:"theme"`
125- CustomerID int `json:"customerId"`
126- DateCreated int64 `json:"dateCreated"`
127- Products []string `json:"products,omitempty"`
128- Show string `json:"show"`
129- Immutable bool `json:"immutable"`
130- CanUseSysdigCapture bool `json:"canUseSysdigCapture"`
131- CanUseCustomEvents bool `json:"canUseCustomEvents"`
132- CanUseAwsMetrics bool `json:"canUseAwsMetrics"`
133- CanUseBeaconMetrics bool `json:"canUseBeaconMetrics"`
134- UserCount int `json:"userCount"`
135- Filter string `json:"filter,omitempty"`
136- DefaultTeam bool `json:"default,omitempty"`
137- }
138-
139- type UserRoles struct {
140- UserId int `json:"userId"`
141- Email string `json:"userName,omitempty"`
142- Role string `json:"role"`
143- Admin bool `json:"admin,omitempty"`
144- }
145-
146- type EntryPoint struct {
147- Module string `json:"module"`
148- Selection string `json:"selection,omitempty"`
149- }
150-
151- func (t * Team ) ToJSON () io.Reader {
152- payload , _ := json .Marshal (* t )
153- return bytes .NewBuffer (payload )
154- }
155-
156- func TeamFromJSON (body []byte ) Team {
157- var result teamWrapper
158- _ = json .Unmarshal (body , & result )
159-
160- return result .Team
161- }
162-
163- type teamWrapper struct {
164- Team Team `json:"team"`
165- }
166-
167- // -------- UsersList --------
168- type UsersList struct {
169- ID int `json:"id"`
170- Email string `json:"username"`
171- }
172-
173- func UsersListFromJSON (body []byte ) []UsersList {
174- var result usersListWrapper
175- _ = json .Unmarshal (body , & result )
176-
177- return result .UsersList
178- }
179-
180- type usersListWrapper struct {
181- UsersList []UsersList `json:"users"`
182- }
183-
18437// -------- Notification Channels --------
18538
18639type NotificationChannelOptions struct {
@@ -210,29 +63,13 @@ type NotificationChannel struct {
21063 Options NotificationChannelOptions `json:"options"`
21164}
21265
213- func (n * NotificationChannel ) ToJSON () io.Reader {
214- payload , _ := json .Marshal (notificationChannelWrapper {* n })
215- return bytes .NewBuffer (payload )
216- }
217-
21866func NotificationChannelFromJSON (body []byte ) NotificationChannel {
21967 var result notificationChannelWrapper
22068 _ = json .Unmarshal (body , & result )
22169
22270 return result .NotificationChannel
22371}
22472
225- func NotificationChannelListFromJSON (body []byte ) []NotificationChannel {
226- var result notificationChannelListWrapper
227- _ = json .Unmarshal (body , & result )
228-
229- return result .NotificationChannels
230- }
231-
232- type notificationChannelListWrapper struct {
233- NotificationChannels []NotificationChannel `json:"notificationChannels"`
234- }
235-
23673type notificationChannelWrapper struct {
23774 NotificationChannel NotificationChannel `json:"notificationChannel"`
23875}
0 commit comments