From 7ab45082ad35cf178307d11b10790018ee4e8ba6 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 12 Mar 2021 16:35:54 +0100 Subject: [PATCH] Sync notifications as well --- cmd/icingadb/main.go | 5 +++ pkg/icingadb/v1/notification.go | 71 +++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 pkg/icingadb/v1/notification.go diff --git a/cmd/icingadb/main.go b/cmd/icingadb/main.go index 6e7b16d4..b4993708 100644 --- a/cmd/icingadb/main.go +++ b/cmd/icingadb/main.go @@ -137,10 +137,15 @@ func main() { v1.NewHostgroupMember, v1.NewIconImage, v1.NewNotesUrl, + v1.NewNotification, v1.NewNotificationcommand, v1.NewNotificationcommandArgument, v1.NewNotificationcommandCustomvar, v1.NewNotificationcommandEnvvar, + v1.NewNotificationCustomvar, + v1.NewNotificationRecipient, + v1.NewNotificationUser, + v1.NewNotificationUsergroup, v1.NewService, v1.NewServiceCustomvar, v1.NewServicegroup, diff --git a/pkg/icingadb/v1/notification.go b/pkg/icingadb/v1/notification.go new file mode 100644 index 00000000..e3256ec5 --- /dev/null +++ b/pkg/icingadb/v1/notification.go @@ -0,0 +1,71 @@ +package v1 + +import ( + "github.com/icinga/icingadb/pkg/contracts" + "github.com/icinga/icingadb/pkg/types" +) + +type Notification struct { + EntityWithChecksum `json:",inline"` + EnvironmentMeta `json:",inline"` + NameCiMeta `json:",inline"` + HostId types.Binary `json:"host_id"` + ServiceId types.Binary `json:"service_id"` + CommandId types.Binary `json:"command_id"` + TimesBegin types.Int `json:"times_begin"` + TimesEnd types.Int `json:"times_end"` + NotificationInterval uint32 `json:"notification_interval"` + TimeperiodId types.Binary `json:"timeperiod_id"` + States uint8 `json:"states"` + Types uint16 `json:"types"` + ZoneId types.Binary `json:"zone_id"` +} + +type NotificationUser struct { + EntityWithoutChecksum `json:",inline"` + EnvironmentMeta `json:",inline"` + NotificationId types.Binary `json:"notification_id"` + UserId types.Binary `json:"user_id"` +} + +type NotificationUsergroup struct { + EntityWithoutChecksum `json:",inline"` + EnvironmentMeta `json:",inline"` + NotificationId types.Binary `json:"notification_id"` + UsergroupId types.Binary `json:"usergroup_id"` +} + +type NotificationRecipient struct { + NotificationUser `json:",inline"` + UsergroupId types.Binary `json:"usergroup_id"` +} + +type NotificationCustomvar struct { + CustomvarMeta `json:",inline"` + NotificationId types.Binary `json:"object_id"` +} + +func NewNotification() contracts.Entity { + return &Notification{} +} + +func NewNotificationUser() contracts.Entity { + return &NotificationUser{} +} + +func NewNotificationUsergroup() contracts.Entity { + return &NotificationUsergroup{} +} + +func NewNotificationRecipient() contracts.Entity { + return &NotificationRecipient{} +} + +func NewNotificationCustomvar() contracts.Entity { + return &NotificationCustomvar{} +} + +// Assert interface compliance. +var ( + _ contracts.Initer = (*Notification)(nil) +)