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