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:
Victor Vrantchan
2017-11-23 22:07:57 -05:00
committed by GitHub
parent bc34ace413
commit 91c236c8c3
112 changed files with 165 additions and 233 deletions

View 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
}