Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@atno/ts-glpi-client

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atno/ts-glpi-client

A (partial)fulltyped GLPI API client

  • 1.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

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
  • Usage
  • Contributing
  • Contributors
  • License

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");

// 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
});

Endpoints

import { GLPIClient } from "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);
		});
});

Contributing

If you would like to contribute to this project, please submit a pull request or open an issue.

Contributors

Gilmar Antonio
Gilmar Antonio

💻 🖋 📖 🤔 🚇 🚧 📆 🔧

License

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

💙 This package was templated with create-typescript-app.

FAQs

Package last updated on 21 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc