-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
resourceUpdatePending.go
68 lines (53 loc) · 1.71 KB
/
resourceUpdatePending.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
package events
import (
"time"
pkgTime "github.com/plgd-dev/hub/v2/pkg/time"
"google.golang.org/protobuf/proto"
)
const eventTypeResourceUpdatePending = "resourceupdatepending"
func (e *ResourceUpdatePending) Version() uint64 {
return e.GetEventMetadata().GetVersion()
}
func (e *ResourceUpdatePending) Marshal() ([]byte, error) {
return proto.Marshal(e)
}
func (e *ResourceUpdatePending) Unmarshal(b []byte) error {
return proto.Unmarshal(b, e)
}
func (e *ResourceUpdatePending) EventType() string {
return eventTypeResourceUpdatePending
}
func (e *ResourceUpdatePending) AggregateID() string {
return e.GetResourceId().ToUUID()
}
func (e *ResourceUpdatePending) GroupID() string {
return e.GetResourceId().GetDeviceId()
}
func (e *ResourceUpdatePending) IsSnapshot() bool {
return false
}
func (e *ResourceUpdatePending) Timestamp() time.Time {
return pkgTime.Unix(0, e.GetEventMetadata().GetTimestamp())
}
func (e *ResourceUpdatePending) CopyData(event *ResourceUpdatePending) {
e.ResourceId = event.GetResourceId()
e.ResourceInterface = event.GetResourceInterface()
e.Content = event.GetContent()
e.AuditContext = event.GetAuditContext()
e.EventMetadata = event.GetEventMetadata()
e.ValidUntil = event.GetValidUntil()
e.OpenTelemetryCarrier = event.GetOpenTelemetryCarrier()
}
func (e *ResourceUpdatePending) CheckInitialized() bool {
return e.GetResourceId() != nil &&
e.GetResourceInterface() != "" &&
e.GetContent() != nil &&
e.GetAuditContext() != nil &&
e.GetEventMetadata() != nil
}
func (e *ResourceUpdatePending) ValidUntilTime() time.Time {
return pkgTime.Unix(0, e.GetValidUntil())
}
func (e *ResourceUpdatePending) IsExpired(now time.Time) bool {
return IsExpired(now, e.ValidUntilTime())
}