Documentation
¶
Overview ¶
Package api defines a consistent Go API for enqueueing or sending APNs pushes to multiple enrollment IDs.
Index ¶
- type APIResult
- type EnrollmentResult
- type Error
- type PushEnqueuer
- func (pe *PushEnqueuer) EnqueueWithPush(ctx context.Context, command *mdm.Command, ids []string, noPush bool) (*APIResult, int, error)
- func (pe *PushEnqueuer) Push(ctx context.Context, ids []string) (*APIResult, int, error)
- func (pe *PushEnqueuer) RawCommandEnqueueWithPush(ctx context.Context, rawCommand []byte, ids []string, noPush bool) (*APIResult, int, error)
- type PushEnqueuerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIResult ¶
type APIResult struct {
// Status is the per-enrollment ID results of push or enqueue APIs.
// Map key is the enrollment ID.
Status map[string]EnrollmentResult `json:"status,omitempty"`
// NoPush signifies if APNs pushes were not enabled for this API call.
NoPush bool `json:"no_push,omitempty"`
// PushError is present if there was an error sending the APNs push notifications.
PushError *Error `json:"push_error,omitempty"`
// EnqueueError is present if there was an error enqueuing the command.
EnqueueError *Error `json:"command_error,omitempty"`
CommandUUID string `json:"command_uuid,omitempty"` // CommandUUID of the enqueued command.
RequestType string `json:"request_type,omitempty"` // RequestType of the enqueued command.
}
APIResult is the result of push or enqueue APIs.
type EnrollmentResult ¶
type EnrollmentResult struct {
// PushError is present if there was an error sending the APNs push notification.
PushError *Error `json:"push_error,omitempty"`
// PushID is the "apns-id" of a successful APNs push notification.
PushID string `json:"push_result,omitempty"`
// EnqueueError is present if there was an error enqueuing the command.
EnqueueError *Error `json:"command_error,omitempty"`
}
EnrollmentResults are the per-enrollment ID results of push or enqueue APIs.
type Error ¶
type Error struct {
Err error
}
Error wraps errors for marshalling and unmarshalling.
func (*Error) MarshalJSON ¶
MarshalJSON renders the contained error as a JSON string.
func (*Error) UnmarshalJSON ¶
UnmarshalJSON overwrites the contained error with a new plain string error.
type PushEnqueuer ¶
type PushEnqueuer struct {
// contains filtered or unexported fields
}
PushEnqueuer can enqueue commands and send APNs pushes.
func NewPushEnqueuer ¶
func NewPushEnqueuer(store storage.CommandEnqueuer, pusher push.Pusher, opts ...PushEnqueuerOption) (*PushEnqueuer, error)
NewPushEnqueuer creates a new push enqueuer.
func (*PushEnqueuer) EnqueueWithPush ¶
func (pe *PushEnqueuer) EnqueueWithPush(ctx context.Context, command *mdm.Command, ids []string, noPush bool) (*APIResult, int, error)
EnqueueWithPush enqueues command and can send APNs pushes to ids. A command cannot be nil while noPush is true. The return integer is an indicator of errors with the actual errors contained within the API result. A 500 value indicates only errors (with no successes). A 207 value indicates some sucesses and some failures. A 200 value indicates no errors (with only successes). Any other value is undefined.
func (*PushEnqueuer) RawCommandEnqueueWithPush ¶
func (pe *PushEnqueuer) RawCommandEnqueueWithPush(ctx context.Context, rawCommand []byte, ids []string, noPush bool) (*APIResult, int, error)
RawCommandEnqueueWithPush enqueues rawCommand and can send APNs pushes to ids. See [EnqueueWithPush] for calling semantics.
type PushEnqueuerOption ¶
type PushEnqueuerOption func(*PushEnqueuer) error
PushEnqueuerOptions configures the push enqueuer.
func WithLogger ¶
func WithLogger(logger log.Logger) PushEnqueuerOption
WithLogger configures a logger on a push enqueuer.