65 lines
1.4 KiB
Go
65 lines
1.4 KiB
Go
package meta
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
type MetaNoAuthProbeStatus struct {
|
|
ID json.Number `json:"id,Number,omitempty"`
|
|
Name string `json:"name,omitempty"`
|
|
}
|
|
|
|
type NoAuthProbeStatusType int
|
|
|
|
const (
|
|
NoAuthProbeStatusTypeACCEPT NoAuthProbeStatusType = 1 + iota
|
|
NoAuthProbeStatusTypeDENY
|
|
NoAuthProbeStatusTypePROCESS
|
|
)
|
|
|
|
var (
|
|
noAuthProbeStatusTypeID = map[NoAuthProbeStatusType]string{
|
|
NoAuthProbeStatusTypeACCEPT: "ACCEPT",
|
|
NoAuthProbeStatusTypeDENY: "DENY",
|
|
NoAuthProbeStatusTypePROCESS: "PROCESS",
|
|
}
|
|
|
|
noAuthProbeStatusTypeName = map[string]NoAuthProbeStatusType{
|
|
"ACCEPT": NoAuthProbeStatusTypeACCEPT,
|
|
"DENY": NoAuthProbeStatusTypeDENY,
|
|
"PROCESS": NoAuthProbeStatusTypePROCESS,
|
|
}
|
|
)
|
|
|
|
func ToNoAuthProbeStatusType(v string) NoAuthProbeStatusType {
|
|
return noAuthProbeStatusTypeName[v]
|
|
}
|
|
|
|
func (ct NoAuthProbeStatusType) String() string {
|
|
return noAuthProbeStatusTypeID[ct]
|
|
}
|
|
|
|
func (ct NoAuthProbeStatusType) MarshalJSON() ([]byte, error) {
|
|
value, ok := noAuthProbeStatusTypeID[ct]
|
|
if !ok {
|
|
return nil, fmt.Errorf("Invalid EnumType[%s] value", ct)
|
|
}
|
|
return json.Marshal(value)
|
|
}
|
|
|
|
func (ct NoAuthProbeStatusType) UnmarshalJSON(b []byte) error {
|
|
var s string
|
|
err := json.Unmarshal(b, &s)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
value, ok := noAuthProbeStatusTypeName[s]
|
|
if !ok {
|
|
return fmt.Errorf("Invalid EnumType[%s] value", s)
|
|
}
|
|
ct = value
|
|
return nil
|
|
}
|