Files
micromdm/platform/queue/command_queued.go
Victor Vrantchan 91c236c8c3 organize essential APIs into platform, workflow and pkg folders (#337)
Add more logic to the way code is organized.

	/pkg -- library code not directly connected to micromdm
	/mdm -- packages meant for the services devices interract with. The MDM protocol.
	/dep -- DEP API and related packages.
	/platform -- Core APIs the server provides. Commands API, Devices API, queue, pubsub etc.
	/workflow -- Packages/API that build on top of platform. Today that's the webhook package.
		     Depending on what ends up here, the workflow folder might become its own repository.
2017-11-23 22:07:57 -05:00

35 lines
863 B
Go

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
}