@atno/ts-glpi-client
v0.1.0
Published
A (partial)fulltyped GLPI API client
Downloads
3
Readme
npm install @atno/ts-glpi-client
yarn add @atno/ts-glpi-client
import { GLPIClient } from "@atno/ts-glpi-client";
const client = new GLPIClient("base_url", "app_token");
// Authenticate with user and password
client.authenticateWithUserAndPassword("user", "password").then((apiClient) => {
// Use apiClient to access other endpoints
});
// Authenticate with a user token
client.authenticateWithToken("user_token").then((apiClient) => {
// Use apiClient to access other endpoints
});
import { GLPIClient } from "@atno/ts-glpi-client";
const client = new GLPIClient("base_url", "app_token");
// Authenticate and get the actives endpoint
client.authenticateWithUserAndPassword("user", "password").then((apiClient) => {
// Access the actives endpoint
const actives = apiClient.actives;
// Retrieve a item by id of specified itemtype from endpoint
apiclient.endpoint
.getById("itemtype", itemID)
.then((item) => {
console.log("Item by ID:", item);
})
.catch((error) => {
console.error("Error retrieving item by ID:", error);
});
// Retrieve all items of specified itemtype from endpoint
apiclient.endpoint
.getAll("itemtype")
.then((items) => {
console.log("All items:", items);
})
.catch((error) => {
console.error("Error retrieving all items:", error);
});
// Update an item of specific itemtype from endpoint
apiclient.endpoint
.update("itemtype", itemID, { field: "value" })
.then((response) => {
console.log("Update response:", response);
})
.catch((error) => {
console.error("Error updating item:", error);
});
// Add a new item of specific itemtype from endpoint
actives
.add("itemtype", { field: "value" })
.then((response) => {
console.log("Add response:", response);
})
.catch((error) => {
console.error("Error adding item:", error);
});
});