diff --git a/discovery/Host.go b/discovery/Host.go index f56ae0e..7061225 100644 --- a/discovery/Host.go +++ b/discovery/Host.go @@ -7,11 +7,14 @@ import ( const ( DefaultOsType = "UNKNOWN" - DefaultHostType = "HOST" DefaultHostVendor = "UNKNOWN" DefaultHostModel = "UNKNOWN" ) +var ( + DefaultHostType = meta.MetaHostTypeEnumHost.String() +) + type Host struct { MetaIPType *meta.MetaIPType `json:"metaIPType,omitempty"` Name string `json:"name,omitempty"` diff --git a/discovery/Service.go b/discovery/Service.go index 205b694..a92d0d9 100644 --- a/discovery/Service.go +++ b/discovery/Service.go @@ -6,11 +6,14 @@ import ( ) const ( - DefaultServiceType = "ETC" DefaultServiceVendor = "UNKNOWN" DefaultServiceVersion = "UNKNOWN" ) +var ( + DefaultServiceType = meta.MetaServiceTypeEnumUNKNOWN.String() +) + type Service struct { MetaCryptoType *meta.MetaCryptoType `json:"metaCryptoType,omitempty"` Key string `json:"key,omitempty"` diff --git a/meta/MetaHostType.go b/meta/MetaHostType.go new file mode 100644 index 0000000..0db46e6 --- /dev/null +++ b/meta/MetaHostType.go @@ -0,0 +1,53 @@ +package meta + +import ( + "encoding/json" + + "git.loafle.net/overflow/model/util" +) + +type MetaHostType struct { + ID json.Number `json:"id,Number,omitempty"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + CreateDate *util.Timestamp `json:"createDate,omitempty"` +} + +type MetaHostTypeEnum int + +const ( + MetaHostTypeEnumHost MetaHostTypeEnum = iota + 1 + MetaHostTypeEnumNAS + MetaHostTypeEnumPrinter + MetaHostTypeEnumRouter +) + +var ( + metaHostTypeEnumID = map[MetaHostTypeEnum]string{ + MetaHostTypeEnumHost: "HOST", + MetaHostTypeEnumNAS: "NAS", + MetaHostTypeEnumPrinter: "PRINTER", + MetaHostTypeEnumRouter: "ROUTER", + } + + metaHostTypeEnumKey = map[string]MetaHostTypeEnum{ + "HOST": MetaHostTypeEnumHost, + "NAS": MetaHostTypeEnumNAS, + "PRINTER": MetaHostTypeEnumPrinter, + "ROUTER": MetaHostTypeEnumRouter, + } +) + +func (e MetaHostTypeEnum) String() string { + return metaHostTypeEnumID[e] +} + +func ToMetaHostTypeEnum(v *MetaHostType) MetaHostTypeEnum { + return metaHostTypeEnumKey[v.Key] +} + +func ToMetaHostType(v MetaHostTypeEnum) *MetaHostType { + return &MetaHostType{ + Key: metaHostTypeEnumID[v], + } +} diff --git a/meta/MetaServiceType.go b/meta/MetaServiceType.go new file mode 100644 index 0000000..1d0e859 --- /dev/null +++ b/meta/MetaServiceType.go @@ -0,0 +1,65 @@ +package meta + +import ( + "encoding/json" + + "git.loafle.net/overflow/model/util" +) + +type MetaServiceType struct { + ID json.Number `json:"id,Number,omitempty"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + CreateDate *util.Timestamp `json:"createDate,omitempty"` +} + +type MetaServiceTypeEnum int + +const ( + MetaServiceTypeEnumUNKNOWN MetaServiceTypeEnum = iota + 1 + MetaServiceTypeEnumNetwork + MetaServiceTypeEnumDatabase + MetaServiceTypeEnumNoSQL + MetaServiceTypeEnumMail + MetaServiceTypeEnumSearch + MetaServiceTypeEnumWeb + MetaServiceTypeEnumWAS +) + +var ( + metaServiceTypeEnumID = map[MetaServiceTypeEnum]string{ + MetaServiceTypeEnumUNKNOWN: "UNKNOWN", + MetaServiceTypeEnumNetwork: "NETWORK", + MetaServiceTypeEnumDatabase: "DATABASE", + MetaServiceTypeEnumNoSQL: "NOSQL", + MetaServiceTypeEnumMail: "MAIL", + MetaServiceTypeEnumSearch: "SEARCH", + MetaServiceTypeEnumWeb: "WEB", + MetaServiceTypeEnumWAS: "WAS", + } + + metaServiceTypeEnumKey = map[string]MetaServiceTypeEnum{ + "UNKNOWN": MetaServiceTypeEnumUNKNOWN, + "NETWORK": MetaServiceTypeEnumNetwork, + "DATABASE": MetaServiceTypeEnumDatabase, + "NOSQL": MetaServiceTypeEnumNoSQL, + "MAIL": MetaServiceTypeEnumMail, + "SEARCH": MetaServiceTypeEnumSearch, + "WEB": MetaServiceTypeEnumWeb, + "WAS": MetaServiceTypeEnumWAS, + } +) + +func (e MetaServiceTypeEnum) String() string { + return metaServiceTypeEnumID[e] +} + +func ToMetaServiceTypeEnum(v *MetaServiceType) MetaServiceTypeEnum { + return metaServiceTypeEnumKey[v.Key] +} + +func ToMetaServiceType(v MetaServiceTypeEnum) *MetaServiceType { + return &MetaServiceType{ + Key: metaServiceTypeEnumID[v], + } +}