node-apple-vpp
This module servers as a NodeJS wrapper around Apple's VPP API. This can be useful when building an MDM server, or anywhere you would like to monitor VPP accounts.
Usage
npm install node-apple-vpp
Methods
All methods return a Promise, except for the constructor
Constructor(options)
options
An object containing the some of the keys below
let options = stoken_path: '/path/to/token.vpptoken' //REQUIRED: Path to VPP Token File country_code: 'au' // Used for content metadata lookups
init()
Used to request the vpp service config. Required to be used before all other methods. The apple VPP API specification states that the service config should be redownloaded every 5 minutes. This module leaves that up to you to implement. An example is given below:
let vpp = stoken_path: 'test.vpptoken'; vpp;
getLicenseBatch(batchToken, sinceModifiedToken)
Retrieves a batch of licenses from VPP. Has assignedOnly set to true to avoid downloading excessive amounts of licenses.
batchToken
The batchToken returned from a previous requestsinceModifiedToken
The sinceModifiedToken from a previous request
Returns:
status: 0 licenses: adamId:645859810 adamIdStr:"645859810" isIrrevocable:false licenseId:967494668 licenseIdStr:"967494668" pricingParam:"STDQ" productTypeId:8 productTypeName:"Application" serialNumber:"C39N3035G68P" status:"Associated" totalCount: 1 totalBatchCount: 1 sinceModifiedToken: "YzA7OSc0pTUoNSSzKLUFJAyQ6CSWgCS88JnkgAAAA=="
getAssets()
Retrieves a listing of assets from VPP. has licenseCounts set to true.
Returns:
status: 0 assets: adamIdStr:"375380948" assignedCount:2 availableCount:8 deviceAssignable:true isIrrevocable:false pricingParam:"STDQ" productTypeId:8 productTypeName:"Application" retiredCount:0 totalCount:10 totalCount: 1
associateLicenseToSerial(asset, serialNumbers)
Associates a given asset to a given array of serial numbers
asset
A required object detailing the asset to assign licenses for
let asset = adamIdStr: "375380948" pricingParam: "STDQ"
serialNumbers
An array containing serial numbers to assign the asset to
let serialNumbers = "C39N3035G68P"
Returns:
status: 0 adamIdStr: "375380948" pricingParam: "STDQ" productTypeId:8 productTypeName:"Application" associations: "serialNumber":"C39N3035G68P" "licenseIdStr":"4"
revokeLicenseToSerial(asset, serialNumbers)
Revokes a given asset from an array of serials
asset
A required object detailing the asset to revoke licenses for
let asset = adamIdStr: "375380948" pricingParam: "STDQ"
serialNumbers
An array containing serial numbers to revoke the asset from
let serialNumbers = "C39N3035G68P"
Returns:
status: 0 adamIdStr: "375380948" pricingParam: "STDQ" productTypeId:8 productTypeName:"Application" disassociations: "serialNumber":"C39N3035G68P" "licenseIdStr":"4"
revokeLicenseByLicenseID(asset, licenseIds)
Revokes given asset for devices/users by a given array of licenseIds
asset
A required object detailing the asset to revoke licenses for
let asset = adamIdStr: "375380948" pricingParam: "STDQ"
licenseIds
An array containing license ids to revoke the asset from
let licenseIds = "4"
Returns:
status: 0 adamIdStr: "375380948" pricingParam: "STDQ" productTypeId:8 productTypeName:"Application" disassociations: "serialNumber":"C39N3035G68P" "licenseIdStr":"4"
Examples
Multi-Batch License Download
A common problem is how to download all the licenses for a given account, as the VPP API requires batch requests for large license numbers. The code below will execute the saving mechanism before it starts the next round of downloads.
let NodeVPP = ;let asyncEach = ; let vpp = stoken_path: 'test.vpptoken' country_code: 'au'; return vpp; { { let roundResponse = {}; return vpp } { return { console; } } return ;}
Testing
To test run npm test