mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-04 16:26:23 +08:00
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.
This commit is contained in:
34
platform/queue/command_queued.go
Normal file
34
platform/queue/command_queued.go
Normal file
@@ -0,0 +1,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
|
||||
}
|
||||
Reference in New Issue
Block a user