Skip to content

As a Module

Rich Infante edited this page Apr 18, 2018 · 8 revisions

Note: API v4 is currently in development, and is on branch feature/report-groups

Running as an external module

To read more about the design decisions that went into v4, read here

Currently, the only exported function is the run() function, documented below. It returns a promise, which then resolves

/**
 * Public interface for the run function.
 *
 * @param {string} report - the report id.
 * @param {Object=} options - report options
 */
export function run(report, options)

Usage examples:

const bt = require('ibackuptool')

// Call the backups.list report.
bt.run('backups.list')
  .then(backups => {
    // Gives you a list of backups.
    console.log(backups)
  }
  
// Call the backup.info report.
// You must provide a backup parameter to this module.
// Most modules will require this.
bt.run('backup.info', { backup: '<backup id here>' })
  .then(info => {
    // Gives you the formatted info about the backup
    console.log(info)
  })

// Call the backup.info report.
// You must provide a backup parameter to this module.
// Most modules will require this.
bt.run('backup.info', { backup: '<backup id here>', raw: true })
  .then(content => {
    // Gives you the raw contents of the backup Info.plist file.
    console.log(content)
  })