command

package
v1.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 19 Imported by: 5

Documentation

Overview

Package command provides utilities for creating MDM Payloads.

Index

Constants

View Source
const (
	// CommandTopic is a PubSub topic that events are published to.
	CommandTopic = "mdm.Command"

	// RawCommandTopic is a PubSub topic that events are published to.
	RawCommandTopic = "mdm.RawCommand"
)

Variables

This section is empty.

Functions

func MakeClearQueueEndpoint added in v1.11.0

func MakeClearQueueEndpoint(svc Service) endpoint.Endpoint

MakeClearQueueEndpoint creates an endpoint which clears device queues.

func MakeNewCommandEndpoint

func MakeNewCommandEndpoint(svc Service) endpoint.Endpoint

MakeNewCommandEndpoint creates an endpoint which creates new MDM Commands.

func MakeNewRawCommandEndpoint added in v1.11.0

func MakeNewRawCommandEndpoint(svc Service) endpoint.Endpoint

MakeNewRawCommandEndpoint creates an endpoint which creates new raw MDM Commands.

func MakeViewQueueEndpoint added in v1.12.0

func MakeViewQueueEndpoint(svc Service) endpoint.Endpoint

MakeViewQueueEndpoint creates an endpoint which views device queues.

func MarshalEvent

func MarshalEvent(e *Event) ([]byte, error)

MarshalEvent serializes an event to a protocol buffer wire format.

func MarshalRawEvent added in v1.11.0

func MarshalRawEvent(e *RawEvent) ([]byte, error)

MarshalRawEvent serializes a RawEvent to a protocol buffer wire format.

func RegisterHTTPHandlers

func RegisterHTTPHandlers(r *mux.Router, e Endpoints, options ...httptransport.ServerOption)

func UnmarshalEvent

func UnmarshalEvent(data []byte, e *Event) error

UnmarshalEvent parses a protocol buffer representation of data into the Event.

func UnmarshalRawEvent added in v1.11.0

func UnmarshalRawEvent(data []byte, e *RawEvent) error

UnmarshalRawEvent parses a protocol buffer representation of data into the RawEvent.

Types

type CommandService

type CommandService struct {
	// contains filtered or unexported fields
}

func New

func New(pub pubsub.Publisher, queue Queue) (*CommandService, error)

func (*CommandService) ClearQueue added in v1.11.0

func (svc *CommandService) ClearQueue(ctx context.Context, udid string) error

func (*CommandService) NewCommand

func (svc *CommandService) NewCommand(ctx context.Context, request *mdm.CommandRequest) (*mdm.CommandPayload, error)

func (*CommandService) NewRawCommand added in v1.11.0

func (svc *CommandService) NewRawCommand(ctx context.Context, cmd *RawCommand) error

func (*CommandService) ViewQueue added in v1.12.0

func (svc *CommandService) ViewQueue(ctx context.Context, udid string) ([]*mdm.Command, error)

type Endpoints

type Endpoints struct {
	NewCommandEndpoint    endpoint.Endpoint
	NewRawCommandEndpoint endpoint.Endpoint
	ClearQueueEndpoint    endpoint.Endpoint
	ViewQueueEndpoint     endpoint.Endpoint
}

func MakeServerEndpoints

func MakeServerEndpoints(s Service, outer endpoint.Middleware, others ...endpoint.Middleware) Endpoints

type Event

type Event struct {
	ID         string
	Time       time.Time
	Payload    *mdm.CommandPayload
	DeviceUDID string
}

func NewEvent

func NewEvent(payload *mdm.CommandPayload, udid string) *Event

NewEvent returns an Event with a unique ID and the current time.

type Queue added in v1.11.0

type Queue interface {
	Clear(context.Context, mdmsvc.CheckinEvent) error
	ViewQueue(context.Context, mdmsvc.CheckinEvent) ([]*mdmsvc.Command, error)
}

Queue is an MDM Command Queue.

type RawCommand added in v1.11.0

type RawCommand struct {
	UDID        string `json:"udid" plist:"-"`
	CommandUUID string `json:"command_uuid"`
	Command     struct {
		RequestType string `json:"request_type"`
	} `json:"command"`
	Raw []byte `plist:"-" json:"payload"`
}

type RawEvent added in v1.11.0

type RawEvent struct {
	CommandUUID string
	Time        time.Time
	DeviceUDID  string
	Payload     []byte
}

func NewRawEvent added in v1.11.0

func NewRawEvent(cmd *RawCommand) *RawEvent

NewRawEvent returns a RawEvent with the current time.

type Service

type Service interface {
	NewCommand(context.Context, *mdm.CommandRequest) (*mdm.CommandPayload, error)
	NewRawCommand(context.Context, *RawCommand) error
	ClearQueue(ctx context.Context, udid string) error
	ViewQueue(ctx context.Context, udid string) ([]*mdmsvc.Command, error)
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL