-
Notifications
You must be signed in to change notification settings - Fork 3
/
destination_metric_type_enumer.go
115 lines (97 loc) · 4.39 KB
/
destination_metric_type_enumer.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
// Code generated by "enumer -type=DestinationMetricType -yaml -linecomment -transform=snake -output destination_metric_type_enumer.go"; DO NOT EDIT.
package shimesaba
import (
"fmt"
"strings"
)
const _DestinationMetricTypeName = "error_budgeterror_budget_remaining_percentageerror_budget_percentageerror_budget_consumptionerror_budget_consumption_percentageuptimefailure_time"
var _DestinationMetricTypeIndex = [...]uint8{0, 12, 45, 68, 92, 127, 133, 145}
const _DestinationMetricTypeLowerName = "error_budgeterror_budget_remaining_percentageerror_budget_percentageerror_budget_consumptionerror_budget_consumption_percentageuptimefailure_time"
func (i DestinationMetricType) String() string {
if i < 0 || i >= DestinationMetricType(len(_DestinationMetricTypeIndex)-1) {
return fmt.Sprintf("DestinationMetricType(%d)", i)
}
return _DestinationMetricTypeName[_DestinationMetricTypeIndex[i]:_DestinationMetricTypeIndex[i+1]]
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _DestinationMetricTypeNoOp() {
var x [1]struct{}
_ = x[ErrorBudget-(0)]
_ = x[ErrorBudgetRemainingPercentage-(1)]
_ = x[ErrorBudgetPercentage-(2)]
_ = x[ErrorBudgetConsumption-(3)]
_ = x[ErrorBudgetConsumptionPercentage-(4)]
_ = x[UpTime-(5)]
_ = x[FailureTime-(6)]
}
var _DestinationMetricTypeValues = []DestinationMetricType{ErrorBudget, ErrorBudgetRemainingPercentage, ErrorBudgetPercentage, ErrorBudgetConsumption, ErrorBudgetConsumptionPercentage, UpTime, FailureTime}
var _DestinationMetricTypeNameToValueMap = map[string]DestinationMetricType{
_DestinationMetricTypeName[0:12]: ErrorBudget,
_DestinationMetricTypeLowerName[0:12]: ErrorBudget,
_DestinationMetricTypeName[12:45]: ErrorBudgetRemainingPercentage,
_DestinationMetricTypeLowerName[12:45]: ErrorBudgetRemainingPercentage,
_DestinationMetricTypeName[45:68]: ErrorBudgetPercentage,
_DestinationMetricTypeLowerName[45:68]: ErrorBudgetPercentage,
_DestinationMetricTypeName[68:92]: ErrorBudgetConsumption,
_DestinationMetricTypeLowerName[68:92]: ErrorBudgetConsumption,
_DestinationMetricTypeName[92:127]: ErrorBudgetConsumptionPercentage,
_DestinationMetricTypeLowerName[92:127]: ErrorBudgetConsumptionPercentage,
_DestinationMetricTypeName[127:133]: UpTime,
_DestinationMetricTypeLowerName[127:133]: UpTime,
_DestinationMetricTypeName[133:145]: FailureTime,
_DestinationMetricTypeLowerName[133:145]: FailureTime,
}
var _DestinationMetricTypeNames = []string{
_DestinationMetricTypeName[0:12],
_DestinationMetricTypeName[12:45],
_DestinationMetricTypeName[45:68],
_DestinationMetricTypeName[68:92],
_DestinationMetricTypeName[92:127],
_DestinationMetricTypeName[127:133],
_DestinationMetricTypeName[133:145],
}
// DestinationMetricTypeString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func DestinationMetricTypeString(s string) (DestinationMetricType, error) {
if val, ok := _DestinationMetricTypeNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _DestinationMetricTypeNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to DestinationMetricType values", s)
}
// DestinationMetricTypeValues returns all values of the enum
func DestinationMetricTypeValues() []DestinationMetricType {
return _DestinationMetricTypeValues
}
// DestinationMetricTypeStrings returns a slice of all String values of the enum
func DestinationMetricTypeStrings() []string {
strs := make([]string, len(_DestinationMetricTypeNames))
copy(strs, _DestinationMetricTypeNames)
return strs
}
// IsADestinationMetricType returns "true" if the value is listed in the enum definition. "false" otherwise
func (i DestinationMetricType) IsADestinationMetricType() bool {
for _, v := range _DestinationMetricTypeValues {
if i == v {
return true
}
}
return false
}
// MarshalYAML implements a YAML Marshaler for DestinationMetricType
func (i DestinationMetricType) MarshalYAML() (interface{}, error) {
return i.String(), nil
}
// UnmarshalYAML implements a YAML Unmarshaler for DestinationMetricType
func (i *DestinationMetricType) UnmarshalYAML(unmarshal func(interface{}) error) error {
var s string
if err := unmarshal(&s); err != nil {
return err
}
var err error
*i, err = DestinationMetricTypeString(s)
return err
}