dep

package module
v0.0.0-...-03ff93d Latest Latest
Warning

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

Go to latest
Published: May 12, 2018 License: MIT Imports: 11 Imported by: 1

README

dep is a client library for working with Apple's Device Enrollment Program

See godoc for detailed usage.

Usage

Configure and create an http client passing the Oauth credentials from the server token.

    config := dep.Config{
        ConsumerKey:    "CK_3a419c0b",
        ConsumerSecret: "CS_3fb23281",
        AccessToken:    "AT_O8473841",
        AccessSecret:   "AS_9d141598",
    }
    client, err := dep.NewClient(config)
    if err != nil {
        // handle err
    }

Use the new DEP client:

    account, err := client.Account()
    if err != nil {
        // handle err
    }

Example

In the examples folder, there's an example that you can try running against the depsim binary.

Documentation

Overview

Package dep is a client library for Apple's Device Enrollment Program

Configure and create an http client passing the Oauth credentials from the server token.

config := dep.Config{
	ConsumerKey:    "CK_3a419c0b",
	ConsumerSecret: "CS_3fb23281",
	AccessToken:    "AT_O8473841",
	AccessSecret:   "AS_9d141598",
}
client := dep.NewClient(config)

Use the new DEP client:

account, err := client.Account()
if err != nil {
	// handle err
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug() func(*Config) error

Debug will preint responses from DEP to stdout.

func ServerURL

func ServerURL(baseURL string) func(*Config) error

ServerURL allows the user to provide a URL for DEP server other than the default useful for testing with depsim

Types

type Account

type Account struct {
	ServerName    string   `json:"server_name"`
	ServerUUID    string   `json:"server_uuid"`
	AdminID       string   `json:"admin_id"`
	FacilitatorID string   `json:"facilitator_id,omitempty"` //deprecated
	OrgName       string   `json:"org_name"`
	OrgEmail      string   `json:"org_email"`
	OrgPhone      string   `json:"org_phone"`
	OrgAddress    string   `json:"org_address"`
	URLs          []string `json:"urls"`
}

Account is a DEP account

type AccountService

type AccountService interface {
	Account() (*Account, error)
}

AccountService communicates with the DEP Account Details endpoint

account, err := client.Account()

type Client

type Client interface {
	AccountService
	DeviceService
	ProfileService
}

Client interacts with DEP

func NewClient

func NewClient(config *Config, options ...func(*Config) error) (Client, error)

NewClient creates a new HTTP client for communicating with DEP

type Config

type Config struct {
	ConsumerKey    string //given by apple
	ConsumerSecret string //given by apple
	AccessToken    string //given by apple
	AccessSecret   string //given by apple

	AuthSessionToken string //requested from DEP using above credentials
	// contains filtered or unexported fields
}

Config is a configuration struct for DEP

type Device

type Device struct {
	SerialNumber       string    `json:"serial_number"`
	Model              string    `json:"model"`
	Description        string    `json:"description"`
	Color              string    `json:"color"`
	AssetTag           string    `json:"asset_tag"`
	ProfileStatus      string    `json:"profile_status"`
	ProfileUUID        string    `json:"profile_uuid,omitempty"`
	ProfileAssignTime  time.Time `json:"profile_assign_time,omitempty"`
	ProfilePushTime    time.Time `json:"profile_push_time,omitempty"`
	DeviceAssignedDate time.Time `json:"device_assigned_date,omitempty"`
	DeviceAssignedBy   string    `json:"device_assigned_by,omitempty"`
	OS                 string    `json:"os,omitempty"`
	DeviceFamily       string    `json:"device_family,omitempty"`
	// sync fields
	OpType string    `json:"op_type,omitempty"`
	OpDate time.Time `json:"op_date,omitempty"`
}

Device is a DEP device

type DeviceDetailsResponse

type DeviceDetailsResponse struct {
	Devices map[string]Device `json:"devices"`
}

DeviceDetailsResponse is a response for a DeviceDetails request

type DeviceRequestOption

type DeviceRequestOption func(*deviceRequestOpts) error

DeviceRequestOption is an optional parameter for the DeviceService API. The option can be used to set Cursor or Limit options for the request.

func Cursor

func Cursor(cursor string) DeviceRequestOption

Cursor is an optional argument that can be added to FetchDevices

func Limit

func Limit(limit int) DeviceRequestOption

Limit is an optional argument that can be passed to FetchDevices and SyncDevices

type DeviceResponse

type DeviceResponse struct {
	Devices      []Device  `json:"devices"`
	Cursor       string    `json:"cursor"`
	FetchedUntil time.Time `json:"fetched_until"`
	MoreToFollow bool      `json:"more_to_follow"`
}

DeviceResponse is a DEP FetchDevices response

type DeviceService

type DeviceService interface {
	FetchDevices(opts ...DeviceRequestOption) (*DeviceResponse, error)
	SyncDevices(cursor string, opts ...DeviceRequestOption) (*DeviceResponse, error)
	DeviceDetails(devices []string) (*DeviceDetailsResponse, error)
}

DeviceService allows fetching and syncing devices, as well as requesting device details

Use (Cursor() and Limit() as optional arguments for Fetch Devices, example:

fetchResponse, err := client.FetchDevices(dep.Limit(100))
if err != nil {
	// handle err
}
fmt.Println(fetchResponse.Devices)

type Profile

type Profile struct {
	ProfileName           string   `json:"profile_name"`
	URL                   string   `json:"url"`
	AllowPairing          bool     `json:"allow_pairing,omitempty"`
	IsSupervised          bool     `json:"is_supervised,omitempty"`
	IsMultiUser           bool     `json:"is_multi_user,omitempty"`
	IsMandatory           bool     `json:"is_mandatory,omitempty"`
	AwaitDeviceConfigured bool     `json:"await_device_configured,omitempty"`
	IsMDMRemovable        bool     `json:"is_mdm_removable"`
	SupportPhoneNumber    string   `json:"support_phone_number,omitempty"`
	AutoAdvanceSetup      bool     `json:"auto_advance_setup,omitempty"`
	SupportEmailAddress   string   `json:"support_email_address,omitempty"`
	OrgMagic              string   `json:"org_magic"`
	AnchorCerts           []string `json:"anchor_certs,omitempty"`
	SupervisingHostCerts  []string `json:"supervising_host_certs,omitempty"`
	SkipSetupItems        []string `json:"skip_setup_items,omitempty"`
	Department            string   `json:"department,omitempty"`
	Devices               []string `json:"devices"`
}

Profile is a DEP setup profile. The profile can be defined, assigned and fetched.

type ProfileResponse

type ProfileResponse struct {
	ProfileUUID string            `json:"profile_uuid"`
	Devices     map[string]string `json:"devices"`
}

ProfileResponse is the response body for Define Profile

type ProfileService

type ProfileService interface {
	DefineProfile(profile *Profile) (*ProfileResponse, error)
	AssignProfile(profileUUID string, devices []string) (*ProfileResponse, error)
	FetchProfile(profileUUID string) (*Profile, error)
}

ProfileService allows Defining, Assigning and Fetching profiles from DEP

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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