TS-GLPI-CLIENT
TS-GLPI-CLIENT is a TypeScript client library for interacting with the GLPI (Gestionnaire Libre de Parc Informatique) API. This library provides a set of classes to perform various operations such as authentication, retrieval, addition, and updating of resources.
Table of Contents
Installation
To install the TS-GLPI-CLIENT library, use npm or yarn:
npm install ts-glpi-client
or
yarn add ts-glpi-client
Usage
GLPIClient
The GLPIClient class is used to manage authentication and create instances of other GLPI API client classes.
import { GLPIClient } from "ts-glpi-client";
const client = new GLPIClient("base_url", "app_token");
client.authenticateWithUserAndPassword("user", "password").then((apiClient) => {
});
client.authenticateWithToken("user_token").then((apiClient) => {
});
Endpoints
import { GLPIClient } from "ts-glpi-client";
const client = new GLPIClient("base_url", "app_token");
client.authenticateWithUserAndPassword("user", "password").then((apiClient) => {
const actives = apiClient.actives;
apiclient.endpoint
.getById("itemtype", itemID)
.then((item) => {
console.log("Item by ID:", item);
})
.catch((error) => {
console.error("Error retrieving item by ID:", error);
});
apiclient.endpoint
.getAll("itemtype")
.then((items) => {
console.log("All items:", items);
})
.catch((error) => {
console.error("Error retrieving all items:", error);
});
apiclient.endpoint
.update("itemtype", itemID, { field: "value" })
.then((response) => {
console.log("Update response:", response);
})
.catch((error) => {
console.error("Error updating item:", error);
});
actives
.add("itemtype", { field: "value" })
.then((response) => {
console.log("Add response:", response);
})
.catch((error) => {
console.error("Error adding item:", error);
});
});
Contributing
If you would like to contribute to this project, please submit a pull request or open an issue.
Contributors
License
This project is licensed under the MIT License - see the LICENSE file for details.
💙 This package was templated with create-typescript-app.