mobileiron

0.2.4 • Public • Published

mobileiron NPM version Dependency Status js-standard-style

Unofficial library for MobileIron's v2 REST API

JSDoc is available here.

Requirements

Developed using Node 5.x, should work with 4.x.

Installation

$ npm install --save mobileiron

Usage

Get UUID of all non-retired devices

const mobileiron = require('mobileiron')
const baseOpts = mobileiron.createBaseOpts('https://xx.mobileiron.net/company/rest', 'apiuser', 'password')
const devicesOpts = mobileiron.createDevicesOpts(baseOpts, ['common.uuid'], 'retired=false', 1)
mobileiron
  .ping(baseOpts)
  .then(() => mobileiron.getDevices(devicesOpts))
  .then(devices => devices.map(device => device['common.uuid']))
  .then(deviceUuids => {
    console.log(`Found ${deviceUuids.length} devices with the following UUIDs:\n${deviceUuids.join('\n')}`)
  })
  .catch(err => {
    console.error('Failed to connect to MobileIron v2 API: %j', err)
  })

App inventory stream example

const Transform = require('stream').Transform
const mobileiron = require('mobileiron')
 
// transform object to string so we can pipe to stdout
class StringifyObject extends Transform {
  constructor () {
    super({ objectMode: true, decodeStrings: false })
  }
 
  _transform (chunk, encoding, cb) {
    cb(null, JSON.stringify(chunk))
  }
}
 
const baseOpts = mobileiron.createBaseOpts('https://xx.mobileiron.net/company/rest', 'apiuser', 'password')
const appOpts = mobileiron.createAppInventoryOpts(baseOpts, 1, ['abc-123', 'def-456'])
mobileiron.createAppInventoryStream(appOpts)
  .pipe(new StringifyObject())
  .pipe(process.stdout)

TODO / Next up

  • tests for devices & app inventory API
  • sort for devices API
  • test how to define multiple queries
  • (?) better error handling (e.g. react to 400, 401 with specific errors)

License

Apache-2.0 © Mathias Ringhof

Readme

Keywords

Package Sidebar

Install

npm i mobileiron

Weekly Downloads

0

Version

0.2.4

License

Apache-2.0

Last publish

Collaborators

  • mathiasringhof