-
Notifications
You must be signed in to change notification settings - Fork 7
/
types.go
316 lines (297 loc) · 10.2 KB
/
types.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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
package gografana
import (
"encoding/json"
"time"
)
// Board represents Grafana dashboard.
type Board struct {
ID uint `json:"id,omitempty"`
UID string `json:"uid"`
Title string `json:"title"`
Tags []string `json:"tags"`
Editable bool `json:"editable"`
HideControls bool `json:"hideControls"`
Style string `json:"style"`
Timezone string `json:"timezone"`
Version uint `json:"version"`
IsStarred bool `json:"isStarred"`
FolderId uint `json:"folderId"`
FolderUid string `json:"folderUid"`
FolderTitle string `json:"folderTitle"`
FolderUrl string `json:"folderUrl"`
Url string `json:"url,omitempty"` //TODO: ??
Rows []*Row `json:"rows"`
}
type CreateDashboardRequest struct {
Board Board `json:"dashboard"`
//The id of the folder to save the dashboard in.
FolderId uint `json:"folderId"`
//Set to true if you want to overwrite existing dashboard with newer version, same dashboard title in folder or same dashboard uid.
Overwrite bool `json:"overwrite,omitempty"`
//Set a commit message for the version history.
Message string `json:"message"`
}
type CreateFolderRequest struct {
UID string `json:"uid"`
Title string `json:"title"`
}
type CreateFolderResponse struct {
ID int `json:"id"`
UID string `json:"uid"`
Title string `json:"title"`
URL string `json:"url"`
HasAcl bool `json:"hasAcl"`
CanSave bool `json:"canSave"`
CanEdit bool `json:"canEdit"`
CanAdmin bool `json:"canAdmin"`
CreatedBy string `json:"createdBy"`
Created time.Time `json:"created"`
UpdatedBy string `json:"updatedBy"`
Updated time.Time `json:"updated"`
Version int `json:"version"`
}
type CreateAPIKeyResponse struct {
Name string `json:"name"`
Key string `json:"key"`
}
/*
Status Codes:
---------------
200 – Created
400 – Errors (invalid json, missing or invalid fields, etc)
401 – Unauthorized
403 – Access denied
412 – Precondition failed
The 412 status code is used for explaing that you cannot create the dashboard and why. There can be different reasons for this:
The dashboard has been changed by someone else, status=version-mismatch
A dashboard with the same name in the folder already exists, status=name-exists
A dashboard with the same uid already exists, status=name-exists
The dashboard belongs to plugin <plugin title>, status=plugin-dashboard
*/
type CreateDashboardResponse struct {
ID uint `json:"id,omitempty"`
UID string `json:"uid"`
Url string `json:"url"`
Status string `json:"status"`
Version uint `json:"version"`
Message string `json:"message,omitempty"`
}
type Panel_5_0 struct {
AliasColors map[string]string `json:"aliasColors"`
Alert *struct {
AlertRuleTags struct {
} `json:"alertRuleTags"`
Conditions []struct {
Evaluator struct {
Params []int64 `json:"params"`
Type string `json:"type"`
} `json:"evaluator"`
Operator struct {
Type string `json:"type"`
} `json:"operator"`
Query struct {
Params []string `json:"params"`
} `json:"query"`
Reducer struct {
Params []interface{} `json:"params"`
Type string `json:"type"`
} `json:"reducer"`
Type string `json:"type"`
} `json:"conditions"`
ExecutionErrorState string `json:"executionErrorState"`
For string `json:"for"`
Frequency string `json:"frequency"`
Handler int `json:"handler"`
Message string `json:"message"`
Name string `json:"name"`
NoDataState string `json:"noDataState"`
Notifications []struct {
ID int `json:"id"`
} `json:"notifications"`
} `json:"alert,omitempty"`
Bars bool `json:"bars"`
DashLength int `json:"dashLength"`
Dashes bool `json:"dashes"`
Datasource string `json:"datasource"`
Fill int `json:"fill"`
GridPos struct {
H int `json:"h"`
W int `json:"w"`
X int `json:"x"`
Y int `json:"y"`
} `json:"gridPos,omitempty"`
ID int `json:"id"`
Legend struct {
Avg bool `json:"avg"`
Current bool `json:"current"`
Max bool `json:"max"`
Min bool `json:"min"`
Show bool `json:"show"`
Total bool `json:"total"`
Values bool `json:"values"`
AlignAsTable bool `json:"alignAsTable"`
} `json:"legend,omitempty"`
Lines bool `json:"lines"`
Linewidth int `json:"linewidth"`
Links []interface{} `json:"links"`
NullPointMode string `json:"nullPointMode"`
Percentage bool `json:"percentage"`
Pointradius int `json:"pointradius"`
Points bool `json:"points"`
Renderer string `json:"renderer"`
SeriesOverrides []interface{} `json:"seriesOverrides"`
SpaceLength int `json:"spaceLength"`
Stack bool `json:"stack"`
SteppedLine bool `json:"steppedLine"`
Targets []struct {
Expr string `json:"expr"`
Format string `json:"format"`
Instant bool `json:"instant"`
IntervalFactor int `json:"intervalFactor"`
LegendFormat string `json:"legendFormat"`
RefID string `json:"refId"`
} `json:"targets"`
Thresholds []interface{} `json:"thresholds"`
TimeFrom interface{} `json:"timeFrom"`
TimeShift interface{} `json:"timeShift"`
Title string `json:"title"`
Tooltip struct {
Shared bool `json:"shared"`
Sort int `json:"sort"`
ValueType string `json:"value_type"`
} `json:"tooltip,omitempty"`
Transparent bool `json:"transparent"`
Type string `json:"type"`
Xaxis struct {
Buckets interface{} `json:"buckets"`
Mode string `json:"mode"`
Name interface{} `json:"name"`
Show bool `json:"show"`
Values []interface{} `json:"values"`
} `json:"xaxis,omitempty"`
Yaxes []struct {
Format string `json:"format"`
Label interface{} `json:"label"`
LogBase int `json:"logBase"`
Max interface{} `json:"max"`
Min interface{} `json:"min"`
Show bool `json:"show"`
} `json:"yaxes,omitempty"`
}
func (p *Panel_5_0) MarshalJSON() ([]byte, error) {
type Alias Panel_5_0
aliasColors := map[string]string{}
if p.AliasColors != nil {
aliasColors = p.AliasColors
}
return json.Marshal(&struct {
AliasColors map[string]string `json:"aliasColors"`
*Alias
}{
AliasColors: aliasColors,
Alias: (*Alias)(p),
})
}
type Row struct {
Title string `json:"title"`
ShowTitle bool `json:"showTitle"`
Collapse bool `json:"collapse"`
Editable bool `json:"editable"`
Height string `json:"height"`
Panels []Panel_5_0 `json:"panels"`
}
type GetDashboardByUIdResponse struct {
Meta struct {
Type string `json:"type"`
CanSave bool `json:"canSave"`
CanEdit bool `json:"canEdit"`
CanAdmin bool `json:"canAdmin"`
CanStar bool `json:"canStar"`
Slug string `json:"slug"`
URL string `json:"url"`
Expires time.Time `json:"expires"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
UpdatedBy string `json:"updatedBy"`
CreatedBy string `json:"createdBy"`
Version int `json:"version"`
HasAcl bool `json:"hasAcl"`
IsFolder bool `json:"isFolder"`
FolderID int `json:"folderId"`
FolderTitle string `json:"folderTitle"`
FolderURL string `json:"folderUrl"`
} `json:"meta"`
Dashboard Board `json:"dashboard"`
}
type DataSource struct {
ID int `json:"id"`
OrgID int `json:"orgId"`
Name string `json:"name"`
Type string `json:"type"`
TypeLogoURL string `json:"typeLogoUrl"`
Access string `json:"access"`
URL string `json:"url"`
Password string `json:"password"`
User string `json:"user"`
Database string `json:"database"`
BasicAuth bool `json:"basicAuth"`
IsDefault bool `json:"isDefault"`
JSONData map[string]interface{} `json:"jsonData"`
ReadOnly bool `json:"readOnly"`
}
type CreateDataSourceResponse struct {
DataSource *DataSource `json:"datasource"`
ID int `json:"id"`
Message string `json:"message"`
Name string `json:"name"`
}
type CreateNotificationChannelResponse struct {
ID int `json:"id"`
UID string `json:"uid"`
Name string `json:"name"`
Type string `json:"type"`
IsDefault bool `json:"isDefault"`
SendReminder bool `json:"sendReminder"`
Settings struct {
Addresses string `json:"addresses"`
} `json:"settings"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
}
type APIKey struct {
ID int `json:"id"`
Name string `json:"name"`
Role string `json:"role"`
}
type Folder struct {
ID int `json:"id"`
UID string `json:"uid"`
Title string `json:"title"`
URL string `json:"url"`
HasACL bool `json:"hasAcl"`
CanSave bool `json:"canSave"`
CanEdit bool `json:"canEdit"`
CanAdmin bool `json:"canAdmin"`
CreatedBy string `json:"createdBy"`
Created time.Time `json:"created"`
UpdatedBy string `json:"updatedBy"`
Updated time.Time `json:"updated"`
Version int `json:"version"`
}
type NotificationChannel struct {
ID int `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
IsDefault bool `json:"isDefault"`
SendReminder bool `json:"sendReminder"`
DisableResolveMessage bool `json:"disableResolveMessage"`
Frequency string `json:"frequency"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
Settings struct {
Addresses string `json:"addresses"`
AutoResolve bool `json:"autoResolve"`
HTTPMethod string `json:"httpMethod"`
UploadImage bool `json:"uploadImage"`
} `json:"settings"`
}