summaryrefslogtreecommitdiffstats
path: root/pkg/icingadb/v1/history/notification.go
blob: 17fd375cae55b63750cf73316d90108e0dd0ecd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package history

import (
	"github.com/icinga/icingadb/pkg/contracts"
	v1 "github.com/icinga/icingadb/pkg/icingadb/v1"
	"github.com/icinga/icingadb/pkg/types"
)

type NotificationHistory struct {
	HistoryTableEntity `json:",inline"`
	HistoryTableMeta   `json:",inline"`
	NotificationId     types.Binary           `json:"notification_id"`
	Type               types.NotificationType `json:"type"`
	SendTime           types.UnixMilli        `json:"send_time"`
	State              uint8                  `json:"state"`
	PreviousHardState  uint8                  `json:"previous_hard_state"`
	Author             string                 `json:"author"`
	Text               types.String           `json:"text"`
	UsersNotified      uint16                 `json:"users_notified"`
}

type UserNotificationHistory struct {
	v1.EntityWithoutChecksum `json:",inline"`
	v1.EnvironmentMeta       `json:",inline"`
	NotificationHistoryId    types.Binary `json:"notification_history_id"`
	UserId                   types.Binary `json:"user_id"`
}

func (u *UserNotificationHistory) Upsert() interface{} {
	return u
}

type HistoryNotification struct {
	HistoryMeta           `json:",inline"`
	NotificationHistoryId types.Binary    `json:"id"`
	EventTime             types.UnixMilli `json:"send_time"`
}

// TableName implements the contracts.TableNamer interface.
func (*HistoryNotification) TableName() string {
	return "history"
}

// Assert interface compliance.
var (
	_ UpserterEntity       = (*NotificationHistory)(nil)
	_ UpserterEntity       = (*UserNotificationHistory)(nil)
	_ contracts.TableNamer = (*HistoryNotification)(nil)
	_ UpserterEntity       = (*HistoryNotification)(nil)
)