GLPI-API

Node module for GLPI REST API

npm version Build Status codecov license

Installation

$ npm install --save glpi-api

Usage

Configuration

const GlpiApi = require('glpi-api');

// Config with user_token
const config = {
  app_token  : 'AHBIwc4M21Q8yaOzrluxojHJRvHTF6gteAlDBaFW',
  apiurl     : 'https://myglpi.com/apirest.php',
  user_token : 'tt5jyPvv311OzjmrJMNh2Gqgu5ovOOy7saE2fI5ha',
};

// or

// Config with basic auth
const config = {
  app_token : 'AHBIwc4M21Q8yaOzrluxojHJRvHTF6gteAlDBaFW',
  apiurl     : 'https://myglpi.com/apirest.php',
  auth      : {
    username : 'glpi',
    password : 'secret',
  },
};

const glpi = new GlpiApi(config);

Examples

Get a ticket

glpi.initSession()
.then(() => glpi.getItem('Ticket', 123456))
.then((ticket) => {
  // Do what you want with your ticket
})
.catch((err) => {
  // Manage error
})
.then(() => glpi.killSession());

Close a ticket

glpi.initSession()
.then(() => glpi.updateItems('Ticket', ticket.id))
.catch((err) => {
  // Manage error
})
.then(() => glpi.killSession());

Test

Tests are only available for cloned repository

$ npm test

Versioning

I use SemVer for versioning.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details