ing
This commit is contained in:
parent
312284ff6d
commit
fac45a284d
14
meta/model/MetaContainer.go
Normal file
14
meta/model/MetaContainer.go
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"git.loafle.net/overflow/commons-go/core/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MetaContainer struct {
|
||||||
|
ID json.Number `json:"id,Number,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
CreateDate util.Timestamp `json:"createDate,omitempty"`
|
||||||
|
}
|
|
@ -11,4 +11,5 @@ type MetaCrawler struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Description string `json:"description,omitempty"`
|
Description string `json:"description,omitempty"`
|
||||||
CreateDate util.Timestamp `json:"createDate,omitempty"`
|
CreateDate util.Timestamp `json:"createDate,omitempty"`
|
||||||
|
Container *MetaContainer `json:"container,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type MetaInfraVendor struct {
|
type MetaInfraVendor 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"`
|
||||||
CreateDate util.Timestamp `json:"createDate,omitempty"`
|
CreateDate util.Timestamp `json:"createDate,omitempty"`
|
||||||
MetaInfraType *MetaInfraType `json:"metaInfraType,omitempty"`
|
InfraType *MetaInfraType `json:"infraType,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type MetaSensorItem struct {
|
type MetaSensorItem struct {
|
||||||
ID json.Number `json:"id,Number,omitempty"`
|
ID json.Number `json:"id,Number,omitempty"`
|
||||||
MetaSensorItemType *MetaSensorItemType `json:"metaSensorItemType,omitempty"`
|
SensorItemType *MetaSensorItemType `json:"sensorItemType,omitempty"`
|
||||||
Key string `json:"key,omitempty"`
|
Key string `json:"key,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
CreateDate util.Timestamp `json:"createDate,omitempty"`
|
CreateDate util.Timestamp `json:"createDate,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
55
probe/constants/container.go
Normal file
55
probe/constants/container.go
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
package constants
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ContainerType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
DISCOVERY ContainerType = iota
|
||||||
|
NETWORK
|
||||||
|
GENERNAL
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
containerTypeID = map[ContainerType]string{
|
||||||
|
DISCOVERY: "DISCOVERY",
|
||||||
|
NETWORK: "NETWORK",
|
||||||
|
GENERNAL: "GENERNAL",
|
||||||
|
}
|
||||||
|
|
||||||
|
containerTypeName = map[string]ContainerType{
|
||||||
|
"DISCOVERY": DISCOVERY,
|
||||||
|
"NETWORK": NETWORK,
|
||||||
|
"GENERNAL": GENERNAL,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (ct ContainerType) String() string {
|
||||||
|
return containerTypeID[ct]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ct ContainerType) MarshalJSON() ([]byte, error) {
|
||||||
|
value, ok := containerTypeID[ct]
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("Invalid EnumType[%s] value", ct)
|
||||||
|
}
|
||||||
|
return json.Marshal(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ct ContainerType) UnmarshalJSON(b []byte) error {
|
||||||
|
var s string
|
||||||
|
err := json.Unmarshal(b, &s)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
value, ok := containerTypeName[s]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("Invalid EnumType[%s] value", s)
|
||||||
|
}
|
||||||
|
ct = value
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user