vpp

package module
v0.0.0-...-eb451c2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2016 License: MIT Imports: 12 Imported by: 0

README

VPP

vpp is a client library for working with Apple's Volume Purchasing Program

Usage

    config := vpp.Config{
    		URL: "vppsim host or leave blank for apple production server",
    		SToken: &SToken{
    			Token:      "VGhpcyBpcyBhIHNhbXBsZSB0ZXh0IHdoaWNoIHdhcyB1c2VkIHRvIGNyZWF0ZSB0aGUgc2ltdWxhdG9yIHRva2VuCg==",
    			ExpDateStr: "expdate generated by vppsim",
    			OrgName:    "Example Inc.",
    		},
    }
	vppClient, err := NewVPPClient(config)
	if err != nil {
		t.Error(err)
	}

TODO

  • Support Retry-After header. NOTE: The date format version of this doesn't match between doco and the simulator.
  • A nice way of retrieving licenses in batches.
  • Respect maxBatchAssociateLicenseCount and maxBatchDisassociateLicenseCount

Documentation

Index

Constants

View Source
const (
	RegStatusRegistered string = "Registered"
	RegStatusAssociated        = "Associated"
	RegStatusRetired           = "Retired"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetsService

type AssetsService interface {
	GetAssets(includeLicenseCounts bool) ([]VPPAssetAssignment, error)
}

AssetsService describes an interface that is capable of reporting on VPP assets and their license counts.

type BatchRequest

type BatchRequest struct {
	BatchToken         string `json:"batchToken,omitempty"`
	SinceModifiedToken string `json:"sinceModifiedToken,omitempty"`
}

BatchRequestOpts is a structure that defines options available when fetching objects in batches (users/licenses)

func (*BatchRequest) HasNext

func (br *BatchRequest) HasNext() bool

type ClientContext

type ClientContext struct {
	Hostname string `json:"hostname,omitempty"`
	GUID     string `json:"guid,omitempty"`
}

ClientContext represents the information about the current MDM which is stored with the VPP service to ensure that two MDM services are not managing the same VPP account.

func NewClientContext

func NewClientContext(hostname string) *ClientContext

type Config

type Config struct {
	URL    *url.URL
	SToken string
	// contains filtered or unexported fields
}

type ConfigService

type ConfigService interface {
	ServiceConfig() (*ServiceConfig, error)
	ClientContext() (string, error)
	UpdateClientContext(clientContext *ClientContext) (string, error)
}

type GetLicensesOption

type GetLicensesOption func(*getLicensesRequestOpts) error

GetLicensesOption describes the signature of the closure returned by a function adding an argument to GetLicenses

type GetUsersOption

type GetUsersOption func(*getUsersRequestOpts) error

GetUsersOption describes the signature of the closure returned by a function adding an argument to GetUsers

func IncludeRetired

func IncludeRetired(include bool) GetUsersOption

IncludeRetired is an argument given to GetUsers to include users that have been retired. Retiring a user disassociates a VPP user ID from its iTunes account and releases all revocable licenses.

type LicenseAssociation

type LicenseAssociation struct {
	ClientUserIDStr string `json:"clientUserIdStr,omitempty"`
	LicenseIDStr    string `json:"licenseIdStr,omitempty"`
	SerialNumber    string `json:"serialNumber,omitempty"`
	*VPPError
}

LicenseAssociation describes an association between a (VPP user OR device serial) and a license

type LicensesService

type LicensesService interface {
	GetLicenses(batch *BatchRequest, opts ...GetLicensesOption) ([]VPPLicense, error)
	AssociateLicense(user *VPPUser, license *VPPLicense) error
	DisassociateLicense(user *VPPUser, license *VPPLicense) error
}

LicensesService describes an interface that can manage VPP licenses

type MetadataService

type MetadataService interface {
}

type PricingParam

type PricingParam string
const (
	PricingParamStd  PricingParam = "STDQ" // Standard Quality
	PricingParamPlus              = "PLUS" // High Quality (Books only)
)

type SToken

type SToken struct {
	Token      string `json:"token"`
	ExpDateStr string `json:"expDate"`
	OrgName    string `json:"orgName"`
}

func DecodeSToken

func DecodeSToken(base64str string) (*SToken, error)

func (*SToken) Base64String

func (t *SToken) Base64String() (string, error)

type ServiceConfig

type ServiceConfig struct {
	InvitationEmailURL               string     `json:"invitationEmailUrl"`
	RegisterUserSrvURL               string     `json:"registerUserSrvUrl"`
	EditUserSrvURL                   string     `json:"editUserSrvUrl"`
	GetUserSrvURL                    string     `json:"getUserSrvUrl"`
	RetireUserSrvURL                 string     `json:"retireUserSrvUrl"`
	GetUsersSrvURL                   string     `json:"getUsersSrvUrl"`
	GetLicensesSrvURL                string     `json:"getLicensesSrvUrl"`
	AssociateLicenseSrvURL           string     `json:"associateLicenseSrvUrl"`
	DisassociateLicenseSrvURL        string     `json:"disassociateLicenseSrvUrl"`
	ClientConfigSrvURL               string     `json:"clientConfigSrvUrl"`
	ErrorCodes                       []VPPError `json:"errorCodes"`
	GetVPPAssetsSrvURL               string     `json:"getVPPAssetsSrvUrl"`
	InvitationEmailUrl               string     `json:"invitationEmailUrl"`
	ManageVPPLicensesByAdamIdSrvURL  string     `json:"manageVPPLicensesByAdamIdSrvUrl"`
	MaxBatchAssociateLicenseCount    int        `json:"maxBatchAssociateLicenseCount"`
	MaxBatchDisassociateLicenseCount int        `json:"maxBatchDisassociateLicenseCount"`
	Status                           int        `json:"status"`
	VPPWebsiteUrl                    string     `json:"vppWebsiteUrl"`
}

type Status

type Status int
const (
	StatusErr Status = iota - 1
	StatusOk
)

type UsersService

type UsersService interface {
	RegisterUser(user *VPPUser) (*VPPUser, error)
	GetUser(*VPPUser) error
	GetUsers(batch *BatchRequest, opts ...GetUsersOption) ([]VPPUser, error)
	RetireUser(user *VPPUser) error
	EditUser(user *VPPUser) error
}

UsersService interface describes the methods available as part of the VPP user management API.

type VPPAsset

type VPPAsset struct {
	AdamID          string       `json:"adamIdStr,omitempty"`
	ProductTypeID   int          `json:"productTypeId,omitempty"`
	PricingParam    PricingParam `json:"pricingParam,omitempty"`
	ProductTypeName string       `json:"productTypeName"`
}

VPPAsset represents a single licenseable item

type VPPAssetAssignment

type VPPAssetAssignment struct {
	AdamIdStr        string       `json:"adamIdStr"`
	AssignedCount    int          `json:"assignedCount"`
	AvailableCount   int          `json:"availableCount"`
	DeviceAssignable bool         `json:"deviceAssignable"`
	IsIrrevocable    bool         `json:"isIrrevocable"`
	PricingParam     PricingParam `json:"pricingParam"`
	ProductTypeId    int          `json:"productTypeId"`
	ProductTypeName  string       `json:"productTypeName"`
	RetiredCount     int          `json:"retiredCount"`
	TotalCount       int          `json:"totalCount"`
}

VPPAssetAssignment represents a single asset/product and its currently available/assigned licenses totals.

type VPPClient

type VPPClient interface {
	NewRequest(method, urlStr string, body interface{}) (*http.Request, error)
	Do(req *http.Request, into interface{}) error

	AssetsService
	ConfigService
	LicensesService
	MetadataService
	UsersService
}

func NewVPPClient

func NewVPPClient(config *Config) (VPPClient, error)

type VPPError

type VPPError struct {
	ErrorMessage string `json:"errorMessage"`
	ErrorNumber  int    `json:"errorNumber"`
}

func (VPPError) Error

func (e VPPError) Error() string

type VPPLicense

type VPPLicense struct {
	LicenseID     string `json:"licenseIdStr,omitempty"`
	IsIrrevocable bool   `json:"isIrrevocable"`
	*VPPAsset
	*VPPUser
}

VPPLicense describes a licensed product (VPPAsset) and its (optional) association with a VPP User.

type VPPUser

type VPPUser struct {
	UserID          int    `json:"userId,omitempty"`
	Email           string `json:"email,omitempty"`
	Status          string `json:"status,omitempty"`
	InviteURL       string `json:"inviteUrl,omitempty"`
	InviteCode      string `json:"inviteCode,omitempty"`
	ClientUserIdStr string `json:"clientUserIdStr,omitempty"`
	ITSIdHash       string `json:"itsIdHash,omitempty"` // empty if no iTunes account has been associated
}

VPPUser describes the attributes of a VPP user. In most cases, ClientUserIdStr should be used over UserID

func NewUser

func NewUser(email string, id string) *VPPUser

NewUser creates a new user by generating a UUID. Under normal circumstances you should use a UUID that is authoritative for your identity platform

Jump to

Keyboard shortcuts

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