/
authtype_enumer.go
86 lines (70 loc) · 2.14 KB
/
authtype_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
// Code generated by "enumer --type=AuthType -json -yaml -trimprefix=AuthType"; DO NOT EDIT.
package admin
import (
"encoding/json"
"fmt"
)
const _AuthTypeName = "ClientSecretPkceExternalCommandDeviceFlow"
var _AuthTypeIndex = [...]uint8{0, 12, 16, 31, 41}
func (i AuthType) String() string {
if i >= AuthType(len(_AuthTypeIndex)-1) {
return fmt.Sprintf("AuthType(%d)", i)
}
return _AuthTypeName[_AuthTypeIndex[i]:_AuthTypeIndex[i+1]]
}
var _AuthTypeValues = []AuthType{0, 1, 2, 3}
var _AuthTypeNameToValueMap = map[string]AuthType{
_AuthTypeName[0:12]: 0,
_AuthTypeName[12:16]: 1,
_AuthTypeName[16:31]: 2,
_AuthTypeName[31:41]: 3,
}
// AuthTypeString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func AuthTypeString(s string) (AuthType, error) {
if val, ok := _AuthTypeNameToValueMap[s]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to AuthType values", s)
}
// AuthTypeValues returns all values of the enum
func AuthTypeValues() []AuthType {
return _AuthTypeValues
}
// IsAAuthType returns "true" if the value is listed in the enum definition. "false" otherwise
func (i AuthType) IsAAuthType() bool {
for _, v := range _AuthTypeValues {
if i == v {
return true
}
}
return false
}
// MarshalJSON implements the json.Marshaler interface for AuthType
func (i AuthType) MarshalJSON() ([]byte, error) {
return json.Marshal(i.String())
}
// UnmarshalJSON implements the json.Unmarshaler interface for AuthType
func (i *AuthType) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return fmt.Errorf("AuthType should be a string, got %s", data)
}
var err error
*i, err = AuthTypeString(s)
return err
}
// MarshalYAML implements a YAML Marshaler for AuthType
func (i AuthType) MarshalYAML() (interface{}, error) {
return i.String(), nil
}
// UnmarshalYAML implements a YAML Unmarshaler for AuthType
func (i *AuthType) UnmarshalYAML(unmarshal func(interface{}) error) error {
var s string
if err := unmarshal(&s); err != nil {
return err
}
var err error
*i, err = AuthTypeString(s)
return err
}