From bb071180972c65d6688d5f996e83cb051149cf33 Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 12 Sep 2018 12:10:59 +0900 Subject: [PATCH] ing --- discovery/Host.go | 5 +++- discovery/Service.go | 5 +++- meta/MetaHostType.go | 53 +++++++++++++++++++++++++++++++++ meta/MetaServiceType.go | 65 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 meta/MetaHostType.go create mode 100644 meta/MetaServiceType.go 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], + } +}