diff --git a/config/external/external.go b/config/external/external.go deleted file mode 100644 index 3221f53..0000000 --- a/config/external/external.go +++ /dev/null @@ -1,13 +0,0 @@ -package external - -import ( - "git.loafle.net/overflow/commons-go/config/external/grpc" - "git.loafle.net/overflow/commons-go/config/external/kafka" - "git.loafle.net/overflow/commons-go/config/external/redis" -) - -type External struct { - GRPC *grpc.GRPC `json:"grpc"` - Kafka *kafka.Kafka `json:"kafka"` - Redis *redis.Redis `json:"redis"` -} diff --git a/annotation/request-mapping.go b/core/annotation/request-mapping.go similarity index 100% rename from annotation/request-mapping.go rename to core/annotation/request-mapping.go diff --git a/annotation/rest-service.go b/core/annotation/rest-service.go similarity index 100% rename from annotation/rest-service.go rename to core/annotation/rest-service.go diff --git a/annotation/rpc-service.go b/core/annotation/rpc-service.go similarity index 100% rename from annotation/rpc-service.go rename to core/annotation/rpc-service.go diff --git a/annotation/service.go b/core/annotation/service.go similarity index 100% rename from annotation/service.go rename to core/annotation/service.go diff --git a/core/interfaces/EndableStarter.go b/core/interfaces/EndableStarter.go new file mode 100644 index 0000000..3c31077 --- /dev/null +++ b/core/interfaces/EndableStarter.go @@ -0,0 +1,5 @@ +package interfaces + +type EndableStarter interface { + EndableStart() (<-chan error, error) +} diff --git a/core/interfaces/Service.go b/core/interfaces/Service.go new file mode 100644 index 0000000..e5b36a6 --- /dev/null +++ b/core/interfaces/Service.go @@ -0,0 +1,6 @@ +package interfaces + +type Service interface { + Starter + Stopper +} diff --git a/core/interfaces/Starter.go b/core/interfaces/Starter.go new file mode 100644 index 0000000..14c8b6e --- /dev/null +++ b/core/interfaces/Starter.go @@ -0,0 +1,5 @@ +package interfaces + +type Starter interface { + Start() error +} diff --git a/core/interfaces/Stopper.go b/core/interfaces/Stopper.go new file mode 100644 index 0000000..d4f0dd1 --- /dev/null +++ b/core/interfaces/Stopper.go @@ -0,0 +1,7 @@ +package interfaces + +import "context" + +type Stopper interface { + Stop(ctx context.Context) error +} diff --git a/core/util/executer.go b/core/util/executer.go new file mode 100644 index 0000000..581d897 --- /dev/null +++ b/core/util/executer.go @@ -0,0 +1,108 @@ +package util + +import ( + "context" + "fmt" + "reflect" + "time" + + "git.loafle.net/overflow/commons-go/core/interfaces" +) + +func ExecuteStarters(instances []interface{}, targetTypes []reflect.Type, reverse bool) error { + ilen := len(instances) + tlen := len(targetTypes) + + if 0 == ilen || 0 == tlen { + return nil + } + + if reverse { + for indexI := tlen - 1; indexI >= 0; indexI-- { + if err := executeStarter(instances, targetTypes[indexI]); nil != err { + return err + } + } + } else { + for indexI := 0; indexI < tlen; indexI++ { + if err := executeStarter(instances, targetTypes[indexI]); nil != err { + return err + } + } + } + return nil +} + +func executeStarter(instances []interface{}, t reflect.Type) error { + i := findInstanceByType(instances, t) + if nil == i { + return fmt.Errorf("Cannot find instance[%s]", t.String()) + } + + s, ok := i.(interfaces.Starter) + if !ok { + return fmt.Errorf("Instance is not Starter[%s]", t.String()) + } + + if err := s.Start(); nil != err { + return err + } + return nil +} + +func ExecuteStoppers(instances []interface{}, targetTypes []reflect.Type, reverse bool) error { + ilen := len(instances) + tlen := len(targetTypes) + + if 0 == ilen || 0 == tlen { + return nil + } + + if reverse { + for indexI := tlen - 1; indexI >= 0; indexI-- { + if err := executeStarter(instances, targetTypes[indexI]); nil != err { + return err + } + } + } else { + for indexI := 0; indexI < tlen; indexI++ { + if err := executeStarter(instances, targetTypes[indexI]); nil != err { + return err + } + } + } + return nil +} + +func executeStopper(instances []interface{}, t reflect.Type) error { + i := findInstanceByType(instances, t) + if nil == i { + return fmt.Errorf("Cannot find instance[%s]", t.String()) + } + + s, ok := i.(interfaces.Stopper) + if !ok { + return fmt.Errorf("Instance is not Stopper[%s]", t.String()) + } + + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + if err := s.Stop(ctx); nil != err { + return err + } + return nil +} + +func findInstanceByType(instances []interface{}, t reflect.Type) interface{} { + if 0 == len(instances) { + return nil + } + + for _, i := range instances { + if reflect.TypeOf(i) == t { + return i + } + } + + return nil +} diff --git a/core/util/timestamp.go b/core/util/timestamp.go new file mode 100644 index 0000000..da5c614 --- /dev/null +++ b/core/util/timestamp.go @@ -0,0 +1,37 @@ +package util + +import ( + "fmt" + "strconv" + "time" +) + +type Timestamp time.Time + +func (t Timestamp) MarshalJSON() ([]byte, error) { + ts := time.Time(t).Unix() + stamp := fmt.Sprint(ts * 1000) + return []byte(stamp), nil +} + +func (t *Timestamp) UnmarshalJSON(b []byte) error { + ts, err := strconv.Atoi(string(b)) + if err != nil { + return err + } + *t = Timestamp(time.Unix(int64(ts)/1000, 0)) + + return nil +} + +func (t Timestamp) String() string { + return time.Time(t).String() +} + +func Now() Timestamp { + return Timestamp(time.Now()) +} + +func Date(year int, month time.Month, day int) Timestamp { + return Timestamp(time.Date(year, month, day, 0, 0, 0, 0, time.UTC)) +} diff --git a/discovery/model/DiscoveryHost.go b/discovery/model/DiscoveryHost.go new file mode 100644 index 0000000..691b419 --- /dev/null +++ b/discovery/model/DiscoveryHost.go @@ -0,0 +1,10 @@ +package model + +type DiscoveryHost struct { + FirstScanRange string `json:"firstScanRange,omitempty"` + LastScanRange string `json:"lastScanRange,omitempty"` + ExcludeHosts []string `json:"excludeHosts,omitempty"` + IncludeHosts []string `json:"includeHosts,omitempty"` + + DiscoveryPort *DiscoveryPort `json:"discoveryPort,omitempty"` +} diff --git a/discovery/model/DiscoveryPort.go b/discovery/model/DiscoveryPort.go new file mode 100644 index 0000000..1368116 --- /dev/null +++ b/discovery/model/DiscoveryPort.go @@ -0,0 +1,28 @@ +package model + +type DiscoveryPort struct { + FirstScanRange int `json:"firstScanRange,omitempty"` + LastScanRange int `json:"lastScanRange,omitempty"` + ExcludePorts []int `json:"excludePorts,omitempty"` + + IncludeTCP bool `json:"includeTCP,omitempty"` + IncludeUDP bool `json:"includeUDP,omitempty"` + + DiscoveryService *DiscoveryService `json:"discoveryService,omitempty"` +} + +func (dp *DiscoveryPort) Contains(port int) bool { + if dp.FirstScanRange > port { + return false + } + if dp.LastScanRange < port { + return false + } + for _, p := range dp.ExcludePorts { + if p == port { + return false + } + } + + return true +} diff --git a/discovery/model/DiscoveryService.go b/discovery/model/DiscoveryService.go new file mode 100644 index 0000000..e518e8e --- /dev/null +++ b/discovery/model/DiscoveryService.go @@ -0,0 +1,5 @@ +package model + +type DiscoveryService struct { + IncludeServices []string `json:"includeServices,omitempty"` +} diff --git a/discovery/model/DiscoveryZone.go b/discovery/model/DiscoveryZone.go new file mode 100644 index 0000000..90b8bac --- /dev/null +++ b/discovery/model/DiscoveryZone.go @@ -0,0 +1,7 @@ +package model + +type DiscoveryZone struct { + ExcludePatterns []string `json:"excludePatterns,omitempty"` + + DiscoveryHost *DiscoveryHost `json:"discoveryHost,omitempty"` +} diff --git a/discovery/model/Host.go b/discovery/model/Host.go new file mode 100644 index 0000000..e6f1d53 --- /dev/null +++ b/discovery/model/Host.go @@ -0,0 +1,18 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type Host struct { + Zone *Zone `json:"zone"` + + ID json.Number `json:"id,Number,omitempty"` + IP string `json:"ip,omitempty"` + Mac string `json:"mac,omitempty"` + OS string `json:"os,omitempty"` + + DiscoveredDate util.Timestamp `json:"discoveredDate,omitempty"` +} diff --git a/discovery/model/Port.go b/discovery/model/Port.go new file mode 100644 index 0000000..cbc02a2 --- /dev/null +++ b/discovery/model/Port.go @@ -0,0 +1,21 @@ +package model + +import ( + "encoding/json" + + "github.com/google/gopacket" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type Port struct { + Host *Host `json:"host,omitempty"` + + ID json.Number `json:"id,Number,omitempty"` + PortType string `json:"portType,omitempty"` + PortNumber json.Number `json:"portNumber,omitempty"` + + DiscoveredDate util.Timestamp `json:"discoveredDate,omitempty"` + + UDPLayer gopacket.Layer `json:"-"` +} diff --git a/discovery/model/Service.go b/discovery/model/Service.go new file mode 100644 index 0000000..437978e --- /dev/null +++ b/discovery/model/Service.go @@ -0,0 +1,17 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type Service struct { + Port *Port `json:"port,omitempty"` + + ID json.Number `json:"id,Number,omitempty"` + CryptoType string `json:"cryptoType,omitempty"` + ServiceName string `json:"serviceName,omitempty"` + + DiscoveredDate util.Timestamp `json:"discoveredDate,omitempty"` +} diff --git a/discovery/model/Zone.go b/discovery/model/Zone.go new file mode 100644 index 0000000..13b8b4a --- /dev/null +++ b/discovery/model/Zone.go @@ -0,0 +1,20 @@ +package model + +import ( + "encoding/json" + "sync" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type Zone struct { + ID json.Number `json:"id,Number,omitempty"` + Network string `json:"network,omitempty"` + IP string `json:"ip,omitempty"` + Iface string `json:"iface,omitempty"` + Mac string `json:"mac,omitempty"` + + DiscoveredDate util.Timestamp `json:"discoveredDate,omitempty"` + + mtx sync.RWMutex `json:"-"` +} diff --git a/domain/model/Domain.go b/domain/model/Domain.go new file mode 100644 index 0000000..7377532 --- /dev/null +++ b/domain/model/Domain.go @@ -0,0 +1,13 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type Domain struct { + ID json.Number `json:"id,Number,omitempty"` + Name string `json:"name,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` +} diff --git a/domain/model/DomainMember.go b/domain/model/DomainMember.go new file mode 100644 index 0000000..c71124f --- /dev/null +++ b/domain/model/DomainMember.go @@ -0,0 +1,15 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" + member "git.loafle.net/overflow/commons-go/member/model" +) + +type DomainMember struct { + ID json.Number `json:"id,Number,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` + Member *member.Member `json:"member,omitempty"` + Domain *Domain `json:"domain,omitempty"` +} diff --git a/external/config/external.go b/external/config/external.go new file mode 100644 index 0000000..5a45cfc --- /dev/null +++ b/external/config/external.go @@ -0,0 +1,7 @@ +package config + +type External struct { + GRPC *GRPC `json:"grpc"` + Kafka *Kafka `json:"kafka"` + Redis *Redis `json:"redis"` +} diff --git a/config/external/grpc/grpc.go b/external/config/grpc.go similarity index 85% rename from config/external/grpc/grpc.go rename to external/config/grpc.go index efbfc69..6a79472 100644 --- a/config/external/grpc/grpc.go +++ b/external/config/grpc.go @@ -1,4 +1,4 @@ -package grpc +package config type GRPC struct { Network string `json:"network"` diff --git a/config/external/kafka/kafka.go b/external/config/kafka.go similarity index 85% rename from config/external/kafka/kafka.go rename to external/config/kafka.go index 91587db..c0ff218 100644 --- a/config/external/kafka/kafka.go +++ b/external/config/kafka.go @@ -1,4 +1,4 @@ -package kafka +package config type Kafka struct { Network string `json:"network"` diff --git a/config/external/redis/redis.go b/external/config/redis.go similarity index 85% rename from config/external/redis/redis.go rename to external/config/redis.go index b3105cc..e2c43e5 100644 --- a/config/external/redis/redis.go +++ b/external/config/redis.go @@ -1,4 +1,4 @@ -package redis +package config type Redis struct { Network string `json:"network"` diff --git a/glide.yaml b/glide.yaml index 2d6247f..59fd733 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,2 +1,4 @@ package: git.loafle.net/overflow/commons-go -import: [] +import: +- package: github.com/google/gopacket + version: ^1.1.14 diff --git a/infra/model/Infra.go b/infra/model/Infra.go new file mode 100644 index 0000000..c3db4ea --- /dev/null +++ b/infra/model/Infra.go @@ -0,0 +1,18 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" + meta "git.loafle.net/overflow/commons-go/meta/model" + probe "git.loafle.net/overflow/commons-go/probe/model" + target "git.loafle.net/overflow/commons-go/target/model" +) + +type Infra struct { + ID json.Number `json:"id,Number,omitempty"` + MetaInfraType *meta.MetaInfraType `json:"type,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` + Probe *probe.Probe `json:"probe,omitempty"` + Target *target.Target `json:"target,omitempty"` +} diff --git a/infra/model/InfraHost.go b/infra/model/InfraHost.go new file mode 100644 index 0000000..7ee3a57 --- /dev/null +++ b/infra/model/InfraHost.go @@ -0,0 +1,15 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type InfraHost struct { + Infra + InfraOS *InfraOS `json:"os,omitempty"` + IP json.Number `json:"ip,omitempty"` + Mac json.Number `json:"mac,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` +} diff --git a/infra/model/InfraMachine.go b/infra/model/InfraMachine.go new file mode 100644 index 0000000..312ea7d --- /dev/null +++ b/infra/model/InfraMachine.go @@ -0,0 +1,9 @@ +package model + +import "git.loafle.net/overflow/commons-go/core/util" + +type InfraMachine struct { + Infra + Meta string `json:"meta,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` +} diff --git a/infra/model/InfraOS.go b/infra/model/InfraOS.go new file mode 100644 index 0000000..db45cec --- /dev/null +++ b/infra/model/InfraOS.go @@ -0,0 +1,14 @@ +package model + +import ( + "git.loafle.net/overflow/commons-go/core/util" + meta "git.loafle.net/overflow/commons-go/meta/model" +) + +type InfraOS struct { + Infra + InfraMachine *InfraMachine `json:"machine,omitempty"` + Meta string `json:"meta,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` + MetaInfraVendor *meta.MetaInfraVendor `json:"vendor,omitempty"` +} diff --git a/infra/model/InfraOSApplication.go b/infra/model/InfraOSApplication.go new file mode 100644 index 0000000..60b4e7d --- /dev/null +++ b/infra/model/InfraOSApplication.go @@ -0,0 +1,10 @@ +package model + +import "git.loafle.net/overflow/commons-go/core/util" + +type InfraOSApplication struct { + Infra + InfraOS *InfraOS `json:"os,omitempty"` + Name string `json:"name,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` +} diff --git a/infra/model/InfraOSDaemon.go b/infra/model/InfraOSDaemon.go new file mode 100644 index 0000000..84b9e75 --- /dev/null +++ b/infra/model/InfraOSDaemon.go @@ -0,0 +1,12 @@ +package model + +import ( + "git.loafle.net/overflow/commons-go/core/util" +) + +type InfraOSDaemon struct { + Infra + InfraOS *InfraOS `json:"os,omitempty"` + Name string `json:"name,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` +} diff --git a/infra/model/InfraOSPort.go b/infra/model/InfraOSPort.go new file mode 100644 index 0000000..f84eb5d --- /dev/null +++ b/infra/model/InfraOSPort.go @@ -0,0 +1,18 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" + meta "git.loafle.net/overflow/commons-go/meta/model" +) + +type InfraOSPort struct { + Infra + InfraOS *InfraOS `json:"os,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` + Port json.Number `json:"port,omitempty"` + PortType string `json:"portType,omitempty"` + MetaInfraVendor *meta.MetaInfraVendor `json:"vendor,omitempty"` + TLSType bool `json:"tlsType,omitempty"` +} diff --git a/infra/model/InfraServiceApplication.go b/infra/model/InfraServiceApplication.go new file mode 100644 index 0000000..92f46eb --- /dev/null +++ b/infra/model/InfraServiceApplication.go @@ -0,0 +1,18 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" + meta "git.loafle.net/overflow/commons-go/meta/model" +) + +type InfraServiceApplication struct { + Infra + InfraHost *InfraHost `json:"host,omitempty"` + PortType string `json:"portType,omitempty"` + Port json.Number `json:"port,omitempty"` + MetaInfraVendor *meta.MetaInfraVendor `json:"vendor,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` + TLSType bool `json:"tlsType,omitempty"` +} diff --git a/member/model/Member.go b/member/model/Member.go new file mode 100644 index 0000000..594b011 --- /dev/null +++ b/member/model/Member.go @@ -0,0 +1,19 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" + meta "git.loafle.net/overflow/commons-go/meta/model" +) + +type Member struct { + ID json.Number `json:"id,Number,omitempty"` + Email string `json:"email,omitempty"` + Pw string `json:"pw,omitempty"` + Name string `json:"name,omitempty"` + Phone string `json:"phone,omitempty"` + CompanyName string `json:"companyName,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` + Status *meta.MetaMemberStatus `json:"status,omitempty"` +} diff --git a/meta/model/MetaCrawler.go b/meta/model/MetaCrawler.go new file mode 100644 index 0000000..c6c070d --- /dev/null +++ b/meta/model/MetaCrawler.go @@ -0,0 +1,14 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type MetaCrawler struct { + ID json.Number `json:"id,Number,omitempty"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` +} diff --git a/meta/model/MetaHistoryType.go b/meta/model/MetaHistoryType.go new file mode 100644 index 0000000..04bc56b --- /dev/null +++ b/meta/model/MetaHistoryType.go @@ -0,0 +1,13 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type MetaHistoryType struct { + ID json.Number `json:"id,Number,omitempty"` + Name string `json:"name,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` +} diff --git a/meta/model/MetaInfraType.go b/meta/model/MetaInfraType.go new file mode 100644 index 0000000..8655349 --- /dev/null +++ b/meta/model/MetaInfraType.go @@ -0,0 +1,13 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type MetaInfraType struct { + ID json.Number `json:"id,Number,omitempty"` + Name string `json:"name,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` +} diff --git a/meta/model/MetaInfraVendor.go b/meta/model/MetaInfraVendor.go new file mode 100644 index 0000000..1695431 --- /dev/null +++ b/meta/model/MetaInfraVendor.go @@ -0,0 +1,14 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type MetaInfraVendor struct { + ID json.Number `json:"id,Number,omitempty"` + Name string `json:"name,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` + MetaInfraType *MetaInfraType `json:"metaInfraType,omitempty"` +} diff --git a/meta/model/MetaMemberStatus.go b/meta/model/MetaMemberStatus.go new file mode 100644 index 0000000..72abe0a --- /dev/null +++ b/meta/model/MetaMemberStatus.go @@ -0,0 +1,8 @@ +package model + +import "encoding/json" + +type MetaMemberStatus struct { + ID json.Number `json:"id,Number,omitempty"` + Name string `json:"name,omitempty"` +} diff --git a/meta/model/MetaNoAuthProbeStatus.go b/meta/model/MetaNoAuthProbeStatus.go new file mode 100644 index 0000000..fdff9a4 --- /dev/null +++ b/meta/model/MetaNoAuthProbeStatus.go @@ -0,0 +1,8 @@ +package model + +import "encoding/json" + +type MetaNoAuthProbeStatus struct { + ID json.Number `json:"id,Number,omitempty"` + Name string `json:"name,omitempty"` +} diff --git a/meta/model/MetaProbeStatus.go b/meta/model/MetaProbeStatus.go new file mode 100644 index 0000000..3135543 --- /dev/null +++ b/meta/model/MetaProbeStatus.go @@ -0,0 +1,8 @@ +package model + +import "encoding/json" + +type MetaProbeStatus struct { + ID json.Number `json:"id,Number,omitempty"` + Name string `json:"name,omitempty"` +} diff --git a/meta/model/MetaProbeTaskType.go b/meta/model/MetaProbeTaskType.go new file mode 100644 index 0000000..d0e9f69 --- /dev/null +++ b/meta/model/MetaProbeTaskType.go @@ -0,0 +1,14 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type MetaProbeTaskType struct { + ID json.Number `json:"id,Number,omitempty"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` +} diff --git a/meta/model/MetaSensorDisplayItem.go b/meta/model/MetaSensorDisplayItem.go new file mode 100644 index 0000000..7f6f243 --- /dev/null +++ b/meta/model/MetaSensorDisplayItem.go @@ -0,0 +1,16 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type MetaSensorDisplayItem struct { + ID json.Number `json:"id,Number,omitempty"` + Name string `json:"name,omitempty"` + Crawler *MetaCrawler `json:"crawler,omitempty"` + Unit *MetaSensorItemUnit `json:"unit,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` + ItemType *MetaSensorItemType `json:"itemType,omitempty"` +} diff --git a/meta/model/MetaSensorItem.go b/meta/model/MetaSensorItem.go new file mode 100644 index 0000000..7979707 --- /dev/null +++ b/meta/model/MetaSensorItem.go @@ -0,0 +1,15 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type MetaSensorItem struct { + ID json.Number `json:"id,Number,omitempty"` + MetaSensorItemType *MetaSensorItemType `json:"metaSensorItemType,omitempty"` + Key string `json:"key,omitempty"` + Name string `json:"name,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` +} diff --git a/meta/model/MetaSensorItemKey.go b/meta/model/MetaSensorItemKey.go new file mode 100644 index 0000000..e14de82 --- /dev/null +++ b/meta/model/MetaSensorItemKey.go @@ -0,0 +1,18 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type MetaSensorItemKey struct { + ID json.Number `json:"id,Number,omitempty"` + Item *MetaSensorItem `json:"item,omitempty"` + Key string `json:"key,omitempty"` + Froms string `json:"froms,omitempty"` + Option string `json:"option,omitempty"` + Crawler *MetaCrawler `json:"crawler,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` + Unit *MetaSensorItemUnit `json:"unit,omitempty"` +} diff --git a/meta/model/MetaSensorItemType.go b/meta/model/MetaSensorItemType.go new file mode 100644 index 0000000..5e134a3 --- /dev/null +++ b/meta/model/MetaSensorItemType.go @@ -0,0 +1,14 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type MetaSensorItemType struct { + ID json.Number `json:"id,Number,omitempty"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` +} diff --git a/meta/model/MetaSensorItemUnit.go b/meta/model/MetaSensorItemUnit.go new file mode 100644 index 0000000..b636d73 --- /dev/null +++ b/meta/model/MetaSensorItemUnit.go @@ -0,0 +1,14 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type MetaSensorItemUnit struct { + ID json.Number `json:"id,Number,omitempty"` + Unit string `json:"unit,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` + Mark string `json:"mark,omitempty"` +} diff --git a/meta/model/MetaSensorStatus.go b/meta/model/MetaSensorStatus.go new file mode 100644 index 0000000..7678e18 --- /dev/null +++ b/meta/model/MetaSensorStatus.go @@ -0,0 +1,8 @@ +package model + +import "encoding/json" + +type MetaSensorStatus struct { + ID json.Number `json:"id,Number,omitempty"` + Name string `json:"name,omitempty"` +} diff --git a/config/probe/auth.go b/noauthprobe/config/auth.go similarity index 90% rename from config/probe/auth.go rename to noauthprobe/config/auth.go index e4168b8..12cb866 100644 --- a/config/probe/auth.go +++ b/noauthprobe/config/auth.go @@ -1,9 +1,9 @@ -package probe +package config import "time" const ( - AuthConfigFileName = "auth.json" + ConfigFileName = "auth.json" ) type AuthStateType int diff --git a/noauthprobe/constants/protocol.go b/noauthprobe/constants/protocol.go new file mode 100644 index 0000000..bcd3fc6 --- /dev/null +++ b/noauthprobe/constants/protocol.go @@ -0,0 +1,18 @@ +package constants + +const ( + HTTPEntry_Auth = "/auth" +) + +const ( + HTTPRequestHeaderKey_NoAuthProbe_Method = "overFlow-NoAuthProbe-Method" + HTTPRequestHeaderKey_NoAuthProbe_Info = "overFlow-NoAuthProbe-Info" + HTTPRequestHeaderKey_NoAuthProbe_TempProbeKey = "overFlow-NoAuthProbe-TempProbeKey" + + HTTPResponseHeaderKey_NoAuthProbe_SetTempProbeKey = "overFlow-NoAuthProbe-SetTempProbeKey" +) + +const ( + HTTPRequestHeaderValue_NoAuthProbe_Method_Regist = "REGIST" + HTTPRequestHeaderValue_NoAuthProbe_Method_Connect = "CONNECT" +) diff --git a/noauthprobe/model/NoAuthProbe.go b/noauthprobe/model/NoAuthProbe.go new file mode 100644 index 0000000..c5ddc1e --- /dev/null +++ b/noauthprobe/model/NoAuthProbe.go @@ -0,0 +1,21 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" + domain "git.loafle.net/overflow/commons-go/domain/model" + meta "git.loafle.net/overflow/commons-go/meta/model" + probe "git.loafle.net/overflow/commons-go/probe/model" +) + +type NoAuthProbe struct { + ID json.Number `json:"id,Number,omitempty"` + Description string `json:"description,omitempty"` + Status *meta.MetaNoAuthProbeStatus `json:"status,omitempty"` + TempProbeKey string `json:"tempProbeKey,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` + APIKey string `json:"apiKey,omitempty"` + Domain *domain.DomainMember `json:"domain,omitempty"` + Probe *probe.Probe `json:"probe,omitempty"` +} diff --git a/noauthprobe/model/NoAuthProbeDescription.go b/noauthprobe/model/NoAuthProbeDescription.go new file mode 100644 index 0000000..5196ca7 --- /dev/null +++ b/noauthprobe/model/NoAuthProbeDescription.go @@ -0,0 +1,6 @@ +package model + +type NoAuthProbeDescription struct { + Host *NoAuthProbeDescriptionHost `json:"host,omitempty"` + Network *NoAuthProbeDescriptionNetwork `json:"network,omitempty"` +} diff --git a/noauthprobe/model/NoAuthProbeDescriptionHost.go b/noauthprobe/model/NoAuthProbeDescriptionHost.go new file mode 100644 index 0000000..f84177f --- /dev/null +++ b/noauthprobe/model/NoAuthProbeDescriptionHost.go @@ -0,0 +1,11 @@ +package model + +type NoAuthProbeDescriptionHost struct { + Name string `json:"name,omitempty"` + OS string `json:"os,omitempty"` + Platform string `json:"paltform,omitempty"` + PlatformFamily string `json:"platformFamily,omitempty"` + PlatformVersion string `json:"platformVersion,omitempty"` + KernelVersion string `json:"kernelVersion,omitempty"` + HostID string `json:"hostID,omitempty"` +} diff --git a/noauthprobe/model/NoAuthProbeDescriptionNetwork.go b/noauthprobe/model/NoAuthProbeDescriptionNetwork.go new file mode 100644 index 0000000..6563f16 --- /dev/null +++ b/noauthprobe/model/NoAuthProbeDescriptionNetwork.go @@ -0,0 +1,8 @@ +package model + +type NoAuthProbeDescriptionNetwork struct { + Name string `json:"name,omitempty"` + Address string `json:"address,omitempty"` + Gateway string `json:"gateway,omitempty"` + MacAddress string `json:"macAddress,omitempty"` +} diff --git a/notification/model/Notification.go b/notification/model/Notification.go new file mode 100644 index 0000000..0e8b906 --- /dev/null +++ b/notification/model/Notification.go @@ -0,0 +1,18 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" + member "git.loafle.net/overflow/commons-go/member/model" +) + +type Notification struct { + ID json.Number `json:"id,Number,omitempty"` + CreateDate util.Timestamp `json:"date,omitempty"` + Title string `json:"title,omitempty"` + Message string `json:"message,omitempty"` + Member *member.Member `json:"member,omitempty"` + ConfirmDate util.Timestamp `json:"confirmDate,omitempty"` + Url string `json:"url,omitempty"` +} diff --git a/config/probe/account.go b/probe/config/account.go similarity index 85% rename from config/probe/account.go rename to probe/config/account.go index 767f487..0db141c 100644 --- a/config/probe/account.go +++ b/probe/config/account.go @@ -1,4 +1,4 @@ -package probe +package config type Account struct { Name string `json:"name"` diff --git a/config/probe/central.go b/probe/config/central.go similarity index 84% rename from config/probe/central.go rename to probe/config/central.go index 76e1f56..07c7bb1 100644 --- a/config/probe/central.go +++ b/probe/config/central.go @@ -1,4 +1,4 @@ -package probe +package config type Central struct { Host string `json:"host"` diff --git a/config/probe/probe.go b/probe/config/probe.go similarity index 95% rename from config/probe/probe.go rename to probe/config/probe.go index dd11d6b..a0a5d35 100644 --- a/config/probe/probe.go +++ b/probe/config/probe.go @@ -1,4 +1,4 @@ -package probe +package config type ProbeStateType int diff --git a/probe/constants/protocol.go b/probe/constants/protocol.go new file mode 100644 index 0000000..8165a29 --- /dev/null +++ b/probe/constants/protocol.go @@ -0,0 +1,17 @@ +package constants + +const ( + HTTPEntry_Probe = "/probe" + HTTPEntry_Data = "/data" +) + +const ( + HTTPRequestHeaderKey_Probe_Method = "overFlow-Probe-Method" + HTTPRequestHeaderKey_Probe_ProbeKey = "overFlow-Probe-ProbeKey" + + HTTPResponseHeaderKey_Probe_SetEncryptionKey = "overFlow-Probe-SetEncryptionKey" +) + +const ( + HTTPRequestHeaderValue_Probe_Method_Connect = "CONNECT" +) diff --git a/probe/model/Probe.go b/probe/model/Probe.go new file mode 100644 index 0000000..6993666 --- /dev/null +++ b/probe/model/Probe.go @@ -0,0 +1,25 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" + domain "git.loafle.net/overflow/commons-go/domain/model" + member "git.loafle.net/overflow/commons-go/member/model" + meta "git.loafle.net/overflow/commons-go/meta/model" +) + +type Probe struct { + ID json.Number `json:"id,Number,omitempty"` + Status *meta.MetaProbeStatus `json:"status,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` + Domain *domain.Domain `json:"domain,omitempty"` + ProbeKey string `json:"probeKey,omitempty"` + EncryptionKey string `json:"encryptionKey,omitempty"` + TargetCount int `json:"targetCount,omitempty"` + SensorCount int `json:"sensorCount,omitempty"` + DisplayName string `json:"displayName,omitempty"` + Cidr string `json:"cidr,omitempty"` + AuthorizeDate util.Timestamp `json:"authorizeDate,omitempty"` + AuthorizeMember *member.Member `json:"authorizeMember,omitempty"` +} diff --git a/probe/model/ProbeTask.go b/probe/model/ProbeTask.go new file mode 100644 index 0000000..e68d83e --- /dev/null +++ b/probe/model/ProbeTask.go @@ -0,0 +1,20 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" + meta "git.loafle.net/overflow/commons-go/meta/model" +) + +type ProbeTask struct { + ID json.Number `json:"id,Number,omitempty"` + MetaProbeTaskType *meta.MetaProbeTaskType `json:"metaProbeTaskType,omitempty"` + Probe *Probe `json:"probe,omitempty"` + Data string `json:"data,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` + SendDate util.Timestamp `json:"sendDate,omitempty"` + StartDate util.Timestamp `json:"startDate,omitempty"` + EndDate util.Timestamp `json:"endDate,omitempty"` + Succeed bool `json:"succeed,omitempty"` +} diff --git a/sensor/model/Sensor.go b/sensor/model/Sensor.go new file mode 100644 index 0000000..3dc9fae --- /dev/null +++ b/sensor/model/Sensor.go @@ -0,0 +1,19 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" + meta "git.loafle.net/overflow/commons-go/meta/model" + target "git.loafle.net/overflow/commons-go/target/model" +) + +type Sensor struct { + ID json.Number `json:"id,Number,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` + Description string `json:"description,omitempty"` + MetaSensorStatus *meta.MetaSensorStatus `json:"status,omitempty"` + Target *target.Target `json:"target,omitempty"` + Crawler *meta.MetaCrawler `json:"crawler,omitempty"` + CrawlerInputItems string `json:"crawlerInputItems,omitempty"` +} diff --git a/sensor/model/SensorItem.go b/sensor/model/SensorItem.go new file mode 100644 index 0000000..898fb16 --- /dev/null +++ b/sensor/model/SensorItem.go @@ -0,0 +1,15 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" + meta "git.loafle.net/overflow/commons-go/meta/model" +) + +type SensorItem struct { + ID json.Number `json:"id,Number,omitempty"` + Sensor *Sensor `json:"sensor,omitempty"` + MetaSensorItem *meta.MetaSensorItem `json:"item,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` +} diff --git a/sensor/model/SensorItemDependency.go b/sensor/model/SensorItemDependency.go new file mode 100644 index 0000000..1cfd9b2 --- /dev/null +++ b/sensor/model/SensorItemDependency.go @@ -0,0 +1,13 @@ +package model + +import ( + "encoding/json" + + meta "git.loafle.net/overflow/commons-go/meta/model" +) + +type SensorItemDependency struct { + ID json.Number `json:"id,Number,omitempty"` + DisplayItem *meta.MetaSensorDisplayItem `json:"displayItem,omitempty"` + SensorItem *meta.MetaSensorItemKey `json:"sensorItem,omitempty"` +} diff --git a/sensorconfig/model/Connection.go b/sensorconfig/model/Connection.go new file mode 100644 index 0000000..df342d4 --- /dev/null +++ b/sensorconfig/model/Connection.go @@ -0,0 +1,10 @@ +package model + +import "encoding/json" + +type Connection struct { + IP string `json:"ip,omitempty"` + Port json.Number `json:"port,Number,omitempty"` + PortType string `json:"portType,omitempty"` + SSL bool `json:"ssl,omitempty"` +} diff --git a/sensorconfig/model/Crawler.go b/sensorconfig/model/Crawler.go new file mode 100644 index 0000000..1da5fd7 --- /dev/null +++ b/sensorconfig/model/Crawler.go @@ -0,0 +1,6 @@ +package model + +type Crawler struct { + Name string `json:"name,omitempty"` + Container string `json:"container,omitempty"` +} diff --git a/sensorconfig/model/Item.go b/sensorconfig/model/Item.go new file mode 100644 index 0000000..d2dc88c --- /dev/null +++ b/sensorconfig/model/Item.go @@ -0,0 +1,7 @@ +package model + +type Item struct { + Keys []Keys `json:"keys,omitempty"` + QueryInfo *QueryInfo `json:"queryInfo,omitempty"` + MappingInfo *MappingInfo `json:"mappingInfo,omitempty"` +} diff --git a/sensorconfig/model/Keys.go b/sensorconfig/model/Keys.go new file mode 100644 index 0000000..36e3534 --- /dev/null +++ b/sensorconfig/model/Keys.go @@ -0,0 +1,6 @@ +package model + +type Keys struct { + Metric string `json:"metric,omitempty"` + Key string `json:"key,omitempty"` +} diff --git a/sensorconfig/model/MappingInfo.go b/sensorconfig/model/MappingInfo.go new file mode 100644 index 0000000..f3b535b --- /dev/null +++ b/sensorconfig/model/MappingInfo.go @@ -0,0 +1,8 @@ +package model + +type MappingInfo struct { + ParseDirection string `json:"parseDirection,omitempty"` + ArrayColumns []string `json:"arrayColumns,omitempty"` + KeyColumns []string `json:"keyColumns,omitempty"` + ValueColumn string `json:"valueColumn,omitempty"` +} diff --git a/sensorconfig/model/QueryInfo.go b/sensorconfig/model/QueryInfo.go new file mode 100644 index 0000000..0a0a257 --- /dev/null +++ b/sensorconfig/model/QueryInfo.go @@ -0,0 +1,6 @@ +package model + +type QueryInfo struct { + Query string `json:"query,omitempty"` + Extend map[string]interface{} `json:"extend,omitempty"` +} diff --git a/sensorconfig/model/ResultSet.go b/sensorconfig/model/ResultSet.go new file mode 100644 index 0000000..f5da3ee --- /dev/null +++ b/sensorconfig/model/ResultSet.go @@ -0,0 +1,46 @@ +package model + +import "encoding/json" + +type ResultSetter interface { + AddRow(row []string) + GetMeta() map[string]json.Number + GetData() map[string]string +} + +type ResultSet struct { + Item *Item `json:"item,omitempty"` + Rows [][]string `json:"rows,omitempty"` + Meta map[string]json.Number `json:"meta,omitempty"` +} + +func (rs *ResultSet) AddRow(row []string) { + rs.Rows = append(rs.Rows, row) +} + +func (rs *ResultSet) GetMeta() map[string]json.Number { + return rs.Meta +} + +func NewResultSet(item *Item) ResultSetter { + if nil == item.MappingInfo { + item.MappingInfo = &MappingInfo{} + } + rs := &ResultSet{} + rs.Item = item + rs.Rows = make([][]string, 0) + + switch item.MappingInfo.ParseDirection { + case "row": + rsr := &ResultSetRow{} + rsr.ResultSet = rs + rsr.setMeta() + return rsr + default: + rsc := &ResultSetCol{} + rsc.ResultSet = rs + rsc.setMeta() + return rsc + } + +} diff --git a/sensorconfig/model/ResultSetCol.go b/sensorconfig/model/ResultSetCol.go new file mode 100644 index 0000000..2570698 --- /dev/null +++ b/sensorconfig/model/ResultSetCol.go @@ -0,0 +1,85 @@ +package model + +import ( + "encoding/json" + "fmt" + "strconv" + "strings" + + cuej "git.loafle.net/commons_go/util/encoding/json" +) + +type ResultSetCol struct { + *ResultSet +} + +func (rsc *ResultSetCol) setMeta() { + meta := rsc.Item.Keys + arrayColumns := rsc.Item.MappingInfo.ArrayColumns + + if nil == rsc.Meta { + rsc.Meta = make(map[string]json.Number, 0) + } + + for i := 0; i < len(meta); i++ { + rsc.Meta[meta[i].Key] = json.Number(strconv.Itoa(i)) + } + + if nil != arrayColumns { + for i := 0; i < len(arrayColumns); i++ { + if _, ok := rsc.Meta[arrayColumns[i]]; ok { + continue + } + rsc.Meta[arrayColumns[i]] = json.Number(strconv.Itoa(i + len(meta))) + } + } +} + +func (rsc *ResultSetCol) GetData() map[string]string { + return rsc.parse() +} + +func (rsc *ResultSetCol) parse() map[string]string { + metrics := rsc.Item.Keys + arrayColumns := rsc.Item.MappingInfo.ArrayColumns + + rm := make(map[string]string, 0) + + for i := 0; i < len(rsc.Rows); i++ { + row := rsc.Rows[i] + for j := 0; j < len(row); j++ { + arrayValue := make([]string, 0) + + if nil != arrayColumns { + for k := 0; k < len(arrayColumns); k++ { + idxN := rsc.Meta[arrayColumns[k]] + idx, _ := cuej.NumberToInt(idxN) + arrayValue = append(arrayValue, row[idx]) + } + } + + for k := 0; k < len(metrics); k++ { + metric := metrics[k].Metric + metric = rsc.convertMetric(metric, arrayValue) + rm[metric] = row[k] + } + + } + } + + return rm +} + +func (rsc *ResultSetCol) convertMetric(metric string, arrayValue []string) string { + if nil == arrayValue || 0 == len(arrayValue) { + return metric + } + + convertChar := "$" + + for i := 0; i < len(arrayValue); i++ { + convertStr := fmt.Sprintf("%s%d", convertChar, i) + metric = strings.Replace(metric, convertStr, arrayValue[i], -1) + } + return metric +} diff --git a/sensorconfig/model/ResultSetRow.go b/sensorconfig/model/ResultSetRow.go new file mode 100644 index 0000000..9043077 --- /dev/null +++ b/sensorconfig/model/ResultSetRow.go @@ -0,0 +1,105 @@ +package model + +import ( + "encoding/json" + "fmt" + "strconv" + "strings" + + cuej "git.loafle.net/commons_go/util/encoding/json" +) + +type ResultSetRow struct { + *ResultSet +} + +func (rsr *ResultSetRow) setMeta() { + meta := make([]string, 0) + arrayColumns := rsr.Item.MappingInfo.ArrayColumns + keyColumns := rsr.Item.MappingInfo.KeyColumns + valueColumn := rsr.Item.MappingInfo.ValueColumn + + if nil != arrayColumns { + for _, c := range arrayColumns { + meta = append(meta, c) + } + } + + if nil != keyColumns { + for _, c := range keyColumns { + meta = append(meta, c) + } + } + + if "" != valueColumn { + meta = append(meta, valueColumn) + } + + if nil == rsr.Meta { + rsr.Meta = make(map[string]json.Number, 0) + } + + for i := 0; i < len(meta); i++ { + rsr.Meta[meta[i]] = json.Number(strconv.Itoa(i)) + } +} + +func (rsr *ResultSetRow) GetData() map[string]string { + return rsr.parse() +} + +func (rsr *ResultSetRow) parse() map[string]string { + valueColumn := rsr.Item.MappingInfo.ValueColumn + + rm := make(map[string]string, 0) + + for _, row := range rsr.Rows { + key := rsr.makeKey(row) + if "" == key { + continue + } + idx, _ := cuej.NumberToInt(rsr.Meta[valueColumn]) + rm[key] = row[idx] + } + + return rm +} + +func (rsr *ResultSetRow) makeKey(data []string) string { + metrics := rsr.Item.Keys + arrayColumns := rsr.Item.MappingInfo.ArrayColumns + keyColumns := rsr.Item.MappingInfo.KeyColumns + keys := rsr.Item.Keys + + findIndex := -1 + +Loop: + for _, keyColumn := range keyColumns { + idx, _ := cuej.NumberToInt(rsr.Meta[keyColumn]) + row := data[idx] + for i := 0; i < len(keys); i++ { + if row == keys[i].Key { + findIndex = i + break Loop + } + } + } + + if 0 > findIndex { + return "" + } + + metric := metrics[findIndex].Metric + + convertChar := "$" + + if nil != arrayColumns { + for i := 0; i < len(arrayColumns); i++ { + convertStr := fmt.Sprintf("%s%d", convertChar, i) + idx, _ := cuej.NumberToInt(rsr.Meta[arrayColumns[i]]) + replaceString := data[idx] + metric = strings.Replace(metric, convertStr, "'"+replaceString+"'", -1) + } + } + return metric +} diff --git a/sensorconfig/model/Schedule.go b/sensorconfig/model/Schedule.go new file mode 100644 index 0000000..6d6c3b3 --- /dev/null +++ b/sensorconfig/model/Schedule.go @@ -0,0 +1,5 @@ +package model + +type Schedule struct { + Interval string `json:"interval,omitempty"` +} diff --git a/sensorconfig/model/SensorConfig.go b/sensorconfig/model/SensorConfig.go new file mode 100644 index 0000000..399b8ab --- /dev/null +++ b/sensorconfig/model/SensorConfig.go @@ -0,0 +1,11 @@ +package model + +import "encoding/json" + +type SensorConfig struct { + ID json.Number `json:"id,Number,omitempty"` + Target *Target `json:"target,omitempty"` + Schedule *Schedule `json:"schedule,omitempty"` + Crawler *Crawler `json:"crawler,omitempty"` + Items []Item `json:"items,omitempty"` +} diff --git a/sensorconfig/model/Target.go b/sensorconfig/model/Target.go new file mode 100644 index 0000000..b9dcdfb --- /dev/null +++ b/sensorconfig/model/Target.go @@ -0,0 +1,6 @@ +package model + +type Target struct { + Auth map[string]interface{} `json:"auth,omitempty"` + Connection *Connection `json:"connection,omitempty"` +} diff --git a/target/model/Target.go b/target/model/Target.go new file mode 100644 index 0000000..fa0d433 --- /dev/null +++ b/target/model/Target.go @@ -0,0 +1,14 @@ +package model + +import ( + "encoding/json" + + "git.loafle.net/overflow/commons-go/core/util" +) + +type Target struct { + ID json.Number `json:"id,Number,omitempty"` + CreateDate util.Timestamp `json:"createDate,omitempty"` + DisplayName string `json:"displayName,omitempty"` + Description string `json:"description,omitempty"` +}