51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package meta
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"git.loafle.net/overflow/model/util"
|
|
)
|
|
|
|
type MetaInfraType struct {
|
|
ID json.Number `json:"id,Number,omitempty"`
|
|
Key string `json:"key,omitempty"`
|
|
Name string `json:"name,omitempty"`
|
|
CreateDate *util.Timestamp `json:"createDate,omitempty"`
|
|
}
|
|
|
|
type MetaInfraTypeEnum int
|
|
|
|
const (
|
|
MetaInfraTypeEnumZONE MetaInfraTypeEnum = iota + 1
|
|
MetaInfraTypeEnumHOST
|
|
MetaInfraTypeEnumService
|
|
)
|
|
|
|
var (
|
|
metaInfraTypeEnumID = map[MetaInfraTypeEnum]string{
|
|
MetaInfraTypeEnumZONE: "ZONE",
|
|
MetaInfraTypeEnumHOST: "HOST",
|
|
MetaInfraTypeEnumService: "SERVICE",
|
|
}
|
|
|
|
metaInfraTypeEnumKey = map[string]MetaInfraTypeEnum{
|
|
"ZONE": MetaInfraTypeEnumZONE,
|
|
"HOST": MetaInfraTypeEnumHOST,
|
|
"SERVICE": MetaInfraTypeEnumService,
|
|
}
|
|
)
|
|
|
|
func (e MetaInfraTypeEnum) String() string {
|
|
return metaInfraTypeEnumID[e]
|
|
}
|
|
|
|
func ToMetaInfraTypeEnum(v *MetaInfraType) MetaInfraTypeEnum {
|
|
return metaInfraTypeEnumKey[v.Key]
|
|
}
|
|
|
|
func ToMetaInfraType(v MetaInfraTypeEnum) *MetaInfraType {
|
|
return &MetaInfraType{
|
|
Key: metaInfraTypeEnumID[v],
|
|
}
|
|
}
|