ing
This commit is contained in:
		
							parent
							
								
									66bdd4681d
								
							
						
					
					
						commit
						4b55b43680
					
				| @ -1,8 +1,64 @@ | |||||||
| package meta | package meta | ||||||
| 
 | 
 | ||||||
| import "encoding/json" | import ( | ||||||
|  | 	"encoding/json" | ||||||
|  | 	"fmt" | ||||||
|  | ) | ||||||
| 
 | 
 | ||||||
| type MetaNoAuthProbeStatus struct { | type MetaNoAuthProbeStatus struct { | ||||||
| 	ID   json.Number `json:"id,Number,omitempty"` | 	ID   json.Number `json:"id,Number,omitempty"` | ||||||
| 	Name string      `json:"name,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 | ||||||
|  | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user