-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenum.go
More file actions
236 lines (225 loc) · 8.69 KB
/
enum.go
File metadata and controls
236 lines (225 loc) · 8.69 KB
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
package llcm
import (
"encoding/json"
"fmt"
)
// OutputType represents the type of output to render.
type OutputType int
const (
OutputTypeNone OutputType = iota // The output type that means none.
OutputTypeJSON // The output type of JSON format.
OutputTypePrettyJSON // The output type of pretty JSON format.
OutputTypeText // The output type of text table format.
OutputTypeCompressedText // The output type of compressed text table format.
OutputTypeMarkdown // The output type of markdown table format.
OutputTypeBacklog // The output type of backlog table format.
OutputTypeTSV // The output type of tab-separated values.
OutputTypeChart // The output type that means pie chart.
)
// String returns the string representation of the OutputType.
func (t OutputType) String() string {
switch t {
case OutputTypeNone:
return "none"
case OutputTypeJSON:
return "json"
case OutputTypePrettyJSON:
return "prettyjson"
case OutputTypeText:
return "text"
case OutputTypeCompressedText:
return "compressedtext"
case OutputTypeMarkdown:
return "markdown"
case OutputTypeBacklog:
return "backlog"
case OutputTypeTSV:
return "tsv"
case OutputTypeChart:
return "chart"
default:
return ""
}
}
// MarshalJSON returns the JSON representation of the OutputType.
func (t OutputType) MarshalJSON() ([]byte, error) {
return json.Marshal(t.String())
}
// ParseOutputType parses a string into an OutputType.
func ParseOutputType(s string) (OutputType, error) {
switch s {
case OutputTypeJSON.String():
return OutputTypeJSON, nil
case OutputTypePrettyJSON.String():
return OutputTypePrettyJSON, nil
case OutputTypeText.String():
return OutputTypeText, nil
case OutputTypeCompressedText.String():
return OutputTypeCompressedText, nil
case OutputTypeMarkdown.String():
return OutputTypeMarkdown, nil
case OutputTypeBacklog.String():
return OutputTypeBacklog, nil
case OutputTypeTSV.String():
return OutputTypeTSV, nil
case OutputTypeChart.String():
return OutputTypeChart, nil
default:
return OutputTypeNone, fmt.Errorf("unsupported output type: %q", s)
}
}
// DesiredState represents the desired state of the log group.
type DesiredState int32
const (
DesiredStateNone DesiredState = -1 // A value meaning none.
DesiredStateZero DesiredState = 0 // A value meaning delete the log group.
DesiredStateOneDay DesiredState = 1 // A value meaning retain the log group for one day.
DesiredStateThreeDays DesiredState = 3 // A value meaning retain the log group for three days.
DesiredStateFiveDays DesiredState = 5 // A value meaning retain the log group for five days.
DesiredStateOneWeek DesiredState = 7 // A value meaning retain the log group for one week.
DesiredStateTwoWeeks DesiredState = 14 // A value meaning retain the log group for two weeks.
DesiredStateOneMonth DesiredState = 30 // A value meaning retain the log group for one month.
DesiredStateTwoMonths DesiredState = 60 // A value meaning retain the log group for two months.
DesiredStateThreeMonths DesiredState = 90 // A value meaning retain the log group for three months.
DesiredStateFourMonths DesiredState = 120 // A value meaning retain the log group for four months.
DesiredStateFiveMonths DesiredState = 150 // A value meaning retain the log group for five months.
DesiredStateSixMonths DesiredState = 180 // A value meaning retain the log group for six months.
DesiredStateOneYear DesiredState = 365 // A value meaning retain the log group for one year.
DesiredStateThirteenMonths DesiredState = 400 // A value meaning retain the log group for thirteen months.
DesiredStateEighteenMonths DesiredState = 545 // A value meaning retain the log group for eighteen months.
DesiredStateTwoYears DesiredState = 731 // A value meaning retain the log group for two years.
DesiredStateThreeYears DesiredState = 1096 // A value meaning retain the log group for three years.
DesiredStateFiveYears DesiredState = 1827 // A value meaning retain the log group for five years.
DesiredStateSixYears DesiredState = 2192 // A value meaning retain the log group for six years.
DesiredStateSevenYears DesiredState = 2557 // A value meaning retain the log group for seven years.
DesiredStateEightYears DesiredState = 2922 // A value meaning retain the log group for eight years.
DesiredStateNineYears DesiredState = 3288 // A value meaning retain the log group for nine years.
DesiredStateTenYears DesiredState = 3653 // A value meaning retain the log group for ten years.
DesiredStateInfinite DesiredState = 9999 // A value meaning retain the log group infinity.
DesiredStateProtected DesiredState = 10000 // A value meaning protect the log group.
DesiredStateUnprotected DesiredState = 10001 // A value meaning unprotect the log group.
)
// String returns the string representation of the DesiredState.
func (t DesiredState) String() string {
switch t {
case DesiredStateNone:
return "none"
case DesiredStateZero:
return "delete"
case DesiredStateOneDay:
return "1day"
case DesiredStateThreeDays:
return "3days"
case DesiredStateFiveDays:
return "5days"
case DesiredStateOneWeek:
return "1week"
case DesiredStateTwoWeeks:
return "2weeks"
case DesiredStateOneMonth:
return "1month"
case DesiredStateTwoMonths:
return "2months"
case DesiredStateThreeMonths:
return "3months"
case DesiredStateFourMonths:
return "4months"
case DesiredStateFiveMonths:
return "5months"
case DesiredStateSixMonths:
return "6months"
case DesiredStateOneYear:
return "1year"
case DesiredStateThirteenMonths:
return "13months"
case DesiredStateEighteenMonths:
return "18months"
case DesiredStateTwoYears:
return "2years"
case DesiredStateThreeYears:
return "3years"
case DesiredStateFiveYears:
return "5years"
case DesiredStateSixYears:
return "6years"
case DesiredStateSevenYears:
return "7years"
case DesiredStateEightYears:
return "8years"
case DesiredStateNineYears:
return "9years"
case DesiredStateTenYears:
return "10years"
case DesiredStateInfinite:
return "infinite"
case DesiredStateProtected:
return "protect"
case DesiredStateUnprotected:
return "unprotect"
default:
return ""
}
}
// MarshalJSON returns the JSON representation of the DesiredState.
func (t DesiredState) MarshalJSON() ([]byte, error) {
return json.Marshal(t.String())
}
// ParseDesiredState parses a string into a DesiredState.
func ParseDesiredState(s string) (DesiredState, error) {
switch s {
case DesiredStateZero.String():
return DesiredStateZero, nil
case DesiredStateOneDay.String():
return DesiredStateOneDay, nil
case DesiredStateThreeDays.String():
return DesiredStateThreeDays, nil
case DesiredStateFiveDays.String():
return DesiredStateFiveDays, nil
case DesiredStateOneWeek.String():
return DesiredStateOneWeek, nil
case DesiredStateTwoWeeks.String():
return DesiredStateTwoWeeks, nil
case DesiredStateOneMonth.String():
return DesiredStateOneMonth, nil
case DesiredStateTwoMonths.String():
return DesiredStateTwoMonths, nil
case DesiredStateThreeMonths.String():
return DesiredStateThreeMonths, nil
case DesiredStateFourMonths.String():
return DesiredStateFourMonths, nil
case DesiredStateFiveMonths.String():
return DesiredStateFiveMonths, nil
case DesiredStateSixMonths.String():
return DesiredStateSixMonths, nil
case DesiredStateOneYear.String():
return DesiredStateOneYear, nil
case DesiredStateThirteenMonths.String():
return DesiredStateThirteenMonths, nil
case DesiredStateEighteenMonths.String():
return DesiredStateEighteenMonths, nil
case DesiredStateTwoYears.String():
return DesiredStateTwoYears, nil
case DesiredStateThreeYears.String():
return DesiredStateThreeYears, nil
case DesiredStateFiveYears.String():
return DesiredStateFiveYears, nil
case DesiredStateSixYears.String():
return DesiredStateSixYears, nil
case DesiredStateSevenYears.String():
return DesiredStateSevenYears, nil
case DesiredStateEightYears.String():
return DesiredStateEightYears, nil
case DesiredStateNineYears.String():
return DesiredStateNineYears, nil
case DesiredStateTenYears.String():
return DesiredStateTenYears, nil
case DesiredStateInfinite.String():
return DesiredStateInfinite, nil
case DesiredStateProtected.String():
return DesiredStateProtected, nil
case DesiredStateUnprotected.String():
return DesiredStateUnprotected, nil
default:
return DesiredStateNone, fmt.Errorf("unsupported desired state: %q", s)
}
}