-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
resourceLinksPublished.go
71 lines (55 loc) · 1.74 KB
/
resourceLinksPublished.go
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package events
import (
"time"
pkgTime "github.com/plgd-dev/hub/v2/pkg/time"
"github.com/plgd-dev/hub/v2/resource-aggregate/commands"
"github.com/plgd-dev/hub/v2/resource-aggregate/cqrs/eventstore"
"google.golang.org/protobuf/proto"
)
const eventTypeResourceLinksPublished = "resourcelinkspublished"
func (e *ResourceLinksPublished) Version() uint64 {
return e.GetEventMetadata().GetVersion()
}
func (e *ResourceLinksPublished) Marshal() ([]byte, error) {
return proto.Marshal(e)
}
func (e *ResourceLinksPublished) Unmarshal(b []byte) error {
return proto.Unmarshal(b, e)
}
func (e *ResourceLinksPublished) EventType() string {
return eventTypeResourceLinksPublished
}
func (e *ResourceLinksPublished) AggregateID() string {
return commands.MakeLinksResourceUUID(e.GetDeviceId()).String()
}
func (e *ResourceLinksPublished) GroupID() string {
return e.GetDeviceId()
}
func (e *ResourceLinksPublished) IsSnapshot() bool {
return false
}
func (e *ResourceLinksPublished) ETag() *eventstore.ETagData {
return nil
}
func (e *ResourceLinksPublished) Timestamp() time.Time {
return pkgTime.Unix(0, e.GetEventMetadata().GetTimestamp())
}
func (e *ResourceLinksPublished) ServiceID() (string, bool) {
return "", false
}
func (e *ResourceLinksPublished) Types() []string {
return nil
}
func (e *ResourceLinksPublished) CopyData(event *ResourceLinksPublished) {
e.Resources = event.GetResources()
e.DeviceId = event.GetDeviceId()
e.AuditContext = event.GetAuditContext()
e.EventMetadata = event.GetEventMetadata()
e.OpenTelemetryCarrier = event.GetOpenTelemetryCarrier()
}
func (e *ResourceLinksPublished) CheckInitialized() bool {
return e.GetResources() != nil &&
e.GetDeviceId() != "" &&
e.GetAuditContext() != nil &&
e.GetEventMetadata() != nil
}