-
Notifications
You must be signed in to change notification settings - Fork 40
/
constants.go
317 lines (285 loc) · 10.1 KB
/
constants.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
317
package diagnostics
import (
"encoding/json"
"fmt"
"strings"
)
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.
type DetectorType string
const (
DetectorTypeAnalysis DetectorType = "Analysis"
DetectorTypeCategoryOverview DetectorType = "CategoryOverview"
DetectorTypeDetector DetectorType = "Detector"
)
func PossibleValuesForDetectorType() []string {
return []string{
string(DetectorTypeAnalysis),
string(DetectorTypeCategoryOverview),
string(DetectorTypeDetector),
}
}
func (s *DetectorType) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseDetectorType(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseDetectorType(input string) (*DetectorType, error) {
vals := map[string]DetectorType{
"analysis": DetectorTypeAnalysis,
"categoryoverview": DetectorTypeCategoryOverview,
"detector": DetectorTypeDetector,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := DetectorType(input)
return &out, nil
}
type InsightStatus string
const (
InsightStatusCritical InsightStatus = "Critical"
InsightStatusInfo InsightStatus = "Info"
InsightStatusNone InsightStatus = "None"
InsightStatusSuccess InsightStatus = "Success"
InsightStatusWarning InsightStatus = "Warning"
)
func PossibleValuesForInsightStatus() []string {
return []string{
string(InsightStatusCritical),
string(InsightStatusInfo),
string(InsightStatusNone),
string(InsightStatusSuccess),
string(InsightStatusWarning),
}
}
func (s *InsightStatus) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseInsightStatus(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseInsightStatus(input string) (*InsightStatus, error) {
vals := map[string]InsightStatus{
"critical": InsightStatusCritical,
"info": InsightStatusInfo,
"none": InsightStatusNone,
"success": InsightStatusSuccess,
"warning": InsightStatusWarning,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := InsightStatus(input)
return &out, nil
}
type IssueType string
const (
IssueTypeAppCrash IssueType = "AppCrash"
IssueTypeAppDeployment IssueType = "AppDeployment"
IssueTypeAseDeployment IssueType = "AseDeployment"
IssueTypeOther IssueType = "Other"
IssueTypePlatformIssue IssueType = "PlatformIssue"
IssueTypeRuntimeIssueDetected IssueType = "RuntimeIssueDetected"
IssueTypeServiceIncident IssueType = "ServiceIncident"
IssueTypeUserIssue IssueType = "UserIssue"
)
func PossibleValuesForIssueType() []string {
return []string{
string(IssueTypeAppCrash),
string(IssueTypeAppDeployment),
string(IssueTypeAseDeployment),
string(IssueTypeOther),
string(IssueTypePlatformIssue),
string(IssueTypeRuntimeIssueDetected),
string(IssueTypeServiceIncident),
string(IssueTypeUserIssue),
}
}
func (s *IssueType) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseIssueType(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseIssueType(input string) (*IssueType, error) {
vals := map[string]IssueType{
"appcrash": IssueTypeAppCrash,
"appdeployment": IssueTypeAppDeployment,
"asedeployment": IssueTypeAseDeployment,
"other": IssueTypeOther,
"platformissue": IssueTypePlatformIssue,
"runtimeissuedetected": IssueTypeRuntimeIssueDetected,
"serviceincident": IssueTypeServiceIncident,
"userissue": IssueTypeUserIssue,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := IssueType(input)
return &out, nil
}
type RenderingType string
const (
RenderingTypeAppInsight RenderingType = "AppInsight"
RenderingTypeAppInsightEnablement RenderingType = "AppInsightEnablement"
RenderingTypeCard RenderingType = "Card"
RenderingTypeChangeAnalysisOnboarding RenderingType = "ChangeAnalysisOnboarding"
RenderingTypeChangeSets RenderingType = "ChangeSets"
RenderingTypeChangesView RenderingType = "ChangesView"
RenderingTypeDataSummary RenderingType = "DataSummary"
RenderingTypeDependencyGraph RenderingType = "DependencyGraph"
RenderingTypeDetector RenderingType = "Detector"
RenderingTypeDownTime RenderingType = "DownTime"
RenderingTypeDropDown RenderingType = "DropDown"
RenderingTypeDynamicInsight RenderingType = "DynamicInsight"
RenderingTypeEmail RenderingType = "Email"
RenderingTypeForm RenderingType = "Form"
RenderingTypeGuage RenderingType = "Guage"
RenderingTypeInsights RenderingType = "Insights"
RenderingTypeMarkdown RenderingType = "Markdown"
RenderingTypeNoGraph RenderingType = "NoGraph"
RenderingTypePieChart RenderingType = "PieChart"
RenderingTypeSearchComponent RenderingType = "SearchComponent"
RenderingTypeSolution RenderingType = "Solution"
RenderingTypeSummaryCard RenderingType = "SummaryCard"
RenderingTypeTable RenderingType = "Table"
RenderingTypeTimeSeries RenderingType = "TimeSeries"
RenderingTypeTimeSeriesPerInstance RenderingType = "TimeSeriesPerInstance"
)
func PossibleValuesForRenderingType() []string {
return []string{
string(RenderingTypeAppInsight),
string(RenderingTypeAppInsightEnablement),
string(RenderingTypeCard),
string(RenderingTypeChangeAnalysisOnboarding),
string(RenderingTypeChangeSets),
string(RenderingTypeChangesView),
string(RenderingTypeDataSummary),
string(RenderingTypeDependencyGraph),
string(RenderingTypeDetector),
string(RenderingTypeDownTime),
string(RenderingTypeDropDown),
string(RenderingTypeDynamicInsight),
string(RenderingTypeEmail),
string(RenderingTypeForm),
string(RenderingTypeGuage),
string(RenderingTypeInsights),
string(RenderingTypeMarkdown),
string(RenderingTypeNoGraph),
string(RenderingTypePieChart),
string(RenderingTypeSearchComponent),
string(RenderingTypeSolution),
string(RenderingTypeSummaryCard),
string(RenderingTypeTable),
string(RenderingTypeTimeSeries),
string(RenderingTypeTimeSeriesPerInstance),
}
}
func (s *RenderingType) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseRenderingType(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseRenderingType(input string) (*RenderingType, error) {
vals := map[string]RenderingType{
"appinsight": RenderingTypeAppInsight,
"appinsightenablement": RenderingTypeAppInsightEnablement,
"card": RenderingTypeCard,
"changeanalysisonboarding": RenderingTypeChangeAnalysisOnboarding,
"changesets": RenderingTypeChangeSets,
"changesview": RenderingTypeChangesView,
"datasummary": RenderingTypeDataSummary,
"dependencygraph": RenderingTypeDependencyGraph,
"detector": RenderingTypeDetector,
"downtime": RenderingTypeDownTime,
"dropdown": RenderingTypeDropDown,
"dynamicinsight": RenderingTypeDynamicInsight,
"email": RenderingTypeEmail,
"form": RenderingTypeForm,
"guage": RenderingTypeGuage,
"insights": RenderingTypeInsights,
"markdown": RenderingTypeMarkdown,
"nograph": RenderingTypeNoGraph,
"piechart": RenderingTypePieChart,
"searchcomponent": RenderingTypeSearchComponent,
"solution": RenderingTypeSolution,
"summarycard": RenderingTypeSummaryCard,
"table": RenderingTypeTable,
"timeseries": RenderingTypeTimeSeries,
"timeseriesperinstance": RenderingTypeTimeSeriesPerInstance,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := RenderingType(input)
return &out, nil
}
type SolutionType string
const (
SolutionTypeBestPractices SolutionType = "BestPractices"
SolutionTypeDeepInvestigation SolutionType = "DeepInvestigation"
SolutionTypeQuickSolution SolutionType = "QuickSolution"
)
func PossibleValuesForSolutionType() []string {
return []string{
string(SolutionTypeBestPractices),
string(SolutionTypeDeepInvestigation),
string(SolutionTypeQuickSolution),
}
}
func (s *SolutionType) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseSolutionType(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseSolutionType(input string) (*SolutionType, error) {
vals := map[string]SolutionType{
"bestpractices": SolutionTypeBestPractices,
"deepinvestigation": SolutionTypeDeepInvestigation,
"quicksolution": SolutionTypeQuickSolution,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := SolutionType(input)
return &out, nil
}