Group related types

This commit is contained in:
Alexander A. Klimov 2021-03-10 18:22:48 +01:00
parent c2fe0dfe7c
commit 66d155cdb3
6 changed files with 33 additions and 52 deletions

View file

@ -2,6 +2,7 @@ package v1
import (
"github.com/icinga/icingadb/pkg/contracts"
"github.com/icinga/icingadb/pkg/types"
)
type Customvar struct {
@ -11,6 +12,15 @@ type Customvar struct {
Value string `json:"value"`
}
type CustomvarFlat struct {
EntityWithoutChecksum `json:",inline"`
EnvironmentMeta `json:",inline"`
CustomvarId types.Binary `json:"customvar_id"`
Flatname string `json:"flatname"`
FlatnameChecksum types.Binary `json:"flatname_checksum"`
Flatvalue string `json:"flatvalue"`
}
func NewCustomvar() contracts.Entity {
return &Customvar{}
}

View file

@ -1,14 +0,0 @@
package v1
import (
"github.com/icinga/icingadb/pkg/types"
)
type CustomvarFlat struct {
EntityWithoutChecksum `json:",inline"`
EnvironmentMeta `json:",inline"`
CustomvarId types.Binary `json:"customvar_id"`
Flatname string `json:"flatname"`
FlatnameChecksum types.Binary `json:"flatname_checksum"`
Flatvalue string `json:"flatvalue"`
}

View file

@ -2,6 +2,7 @@ package v1
import (
"github.com/icinga/icingadb/pkg/contracts"
"github.com/icinga/icingadb/pkg/types"
)
type Host struct {
@ -10,10 +11,21 @@ type Host struct {
Address6 string `json:"address6"`
}
type HostCustomvar struct {
EntityWithoutChecksum `json:",inline"`
EnvironmentMeta `json:",inline"`
HostId types.Binary `json:"object_id"`
CustomvarId types.Binary `json:"customvar_id"`
}
func NewHost() contracts.Entity {
return &Host{}
}
func NewHostCustomvar() contracts.Entity {
return &HostCustomvar{}
}
// Assert interface compliance.
var (
_ contracts.Initer = (*Host)(nil)

View file

@ -1,19 +0,0 @@
package v1
import (
"github.com/icinga/icingadb/pkg/contracts"
"github.com/icinga/icingadb/pkg/types"
)
type HostCustomvar struct {
EntityWithoutChecksum `json:",inline"`
EnvironmentMeta `json:",inline"`
HostId types.Binary `json:"object_id"`
CustomvarId types.Binary `json:"customvar_id"`
}
func NewHostCustomvar() contracts.Entity {
cv := &HostCustomvar{}
return cv
}

View file

@ -10,10 +10,21 @@ type Service struct {
HostId types.Binary `json:"host_id"`
}
type ServiceCustomvar struct {
EntityWithoutChecksum `json:",inline"`
EnvironmentMeta `json:",inline"`
ServiceId types.Binary `json:"object_id"`
CustomvarId types.Binary `json:"customvar_id"`
}
func NewService() contracts.Entity {
return &Service{}
}
func NewServiceCustomvar() contracts.Entity {
return &ServiceCustomvar{}
}
// Assert interface compliance.
var (
_ contracts.Initer = (*Service)(nil)

View file

@ -1,19 +0,0 @@
package v1
import (
"github.com/icinga/icingadb/pkg/contracts"
"github.com/icinga/icingadb/pkg/types"
)
type ServiceCustomvar struct {
EntityWithoutChecksum `json:",inline"`
EnvironmentMeta `json:",inline"`
ServiceId types.Binary `json:"object_id"`
CustomvarId types.Binary `json:"customvar_id"`
}
func NewServiceCustomvar() contracts.Entity {
cv := &ServiceCustomvar{}
return cv
}