forked from micromdm/micromdm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
command_queued.go
34 lines (29 loc) · 863 Bytes
/
command_queued.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
package queue
import (
"errors"
"github.com/gogo/protobuf/proto"
"github.com/micromdm/micromdm/platform/queue/internal/commandqueuedproto"
)
type QueueCommandQueued struct {
DeviceUDID string
CommandUUID string
}
func MarshalQueuedCommand(cq *QueueCommandQueued) ([]byte, error) {
if cq == nil {
return nil, errors.New("marshalling nil QueueCommandQueued")
}
return proto.Marshal(&commandqueued.CommandQueued{
DeviceUdid: cq.DeviceUDID,
CommandUuid: cq.DeviceUDID,
})
}
func UnmarshalQueuedCommand(data []byte) (*QueueCommandQueued, error) {
cmdQueued := commandqueued.CommandQueued{}
if err := proto.Unmarshal(data, &cmdQueued); err != nil {
return nil, err
}
queueCmdQueued := new(QueueCommandQueued)
queueCmdQueued.DeviceUDID = cmdQueued.DeviceUdid
queueCmdQueued.CommandUUID = cmdQueued.CommandUuid
return queueCmdQueued, nil
}