/
availabilitydata.go
111 lines (89 loc) · 3.17 KB
/
availabilitydata.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
package contracts
// NOTE: This file was automatically generated.
// Instances of AvailabilityData represent the result of executing an
// availability test.
type AvailabilityData struct {
Domain
// Schema version
Ver int `json:"ver"`
// Identifier of a test run. Use it to correlate steps of test run and
// telemetry generated by the service.
Id string `json:"id"`
// Name of the test that these availability results represent.
Name string `json:"name"`
// Duration in format: DD.HH:MM:SS.MMMMMM. Must be less than 1000 days.
Duration string `json:"duration"`
// Success flag.
Success bool `json:"success"`
// Name of the location where the test was run from.
RunLocation string `json:"runLocation"`
// Diagnostic message for the result.
Message string `json:"message"`
// Collection of custom properties.
Properties map[string]string `json:"properties,omitempty"`
// Collection of custom measurements.
Measurements map[string]float64 `json:"measurements,omitempty"`
}
// Returns the name used when this is embedded within an Envelope container.
func (data *AvailabilityData) EnvelopeName(key string) string {
if key != "" {
return "Microsoft.ApplicationInsights." + key + ".Availability"
} else {
return "Microsoft.ApplicationInsights.Availability"
}
}
// Returns the base type when placed within a Data object container.
func (data *AvailabilityData) BaseType() string {
return "AvailabilityData"
}
// Truncates string fields that exceed their maximum supported sizes for this
// object and all objects it references. Returns a warning for each affected
// field.
func (data *AvailabilityData) Sanitize() []string {
var warnings []string
if len(data.Id) > 64 {
data.Id = data.Id[:64]
warnings = append(warnings, "AvailabilityData.Id exceeded maximum length of 64")
}
if len(data.Name) > 1024 {
data.Name = data.Name[:1024]
warnings = append(warnings, "AvailabilityData.Name exceeded maximum length of 1024")
}
if len(data.RunLocation) > 1024 {
data.RunLocation = data.RunLocation[:1024]
warnings = append(warnings, "AvailabilityData.RunLocation exceeded maximum length of 1024")
}
if len(data.Message) > 8192 {
data.Message = data.Message[:8192]
warnings = append(warnings, "AvailabilityData.Message exceeded maximum length of 8192")
}
if data.Properties != nil {
for k, v := range data.Properties {
if len(v) > 8192 {
data.Properties[k] = v[:8192]
warnings = append(warnings, "AvailabilityData.Properties has value with length exceeding max of 8192: "+k)
}
if len(k) > 150 {
data.Properties[k[:150]] = data.Properties[k]
delete(data.Properties, k)
warnings = append(warnings, "AvailabilityData.Properties has key with length exceeding max of 150: "+k)
}
}
}
if data.Measurements != nil {
for k, v := range data.Measurements {
if len(k) > 150 {
data.Measurements[k[:150]] = v
delete(data.Measurements, k)
warnings = append(warnings, "AvailabilityData.Measurements has key with length exceeding max of 150: "+k)
}
}
}
return warnings
}
// Creates a new AvailabilityData instance with default values set by the schema.
func NewAvailabilityData() *AvailabilityData {
return &AvailabilityData{
Ver: 2,
}
}