GLPI API Abstraction Layer
This project provides an abstraction layer to simplify the use of the GLPI REST API, making it easier to interact with entities, tickets, and users. It offers a Python interface to streamline communication with the GLPI API in an organized and reusable way.
Repository
Github: https://github.com/Gnew-Solucoes-IP-Ltda/glpi-provider
Requirements
- Python 3.10 +
- Library for GLPI API communication
Structure
The project includes the GlpiProvider class in glpi_provider, which encapsulates various methods to interact with the GLPI API:
-
Authentication:
create_session(): Creates an authentication session with the API.close_session(): Ends the authentication session.
-
Entities:
get_entity(entity_id: int): Retrieves a specific entity by its ID.get_entities(): Retrieves all entities.
-
Tickets:
get_ticket(ticket_id: int): Retrieves a specific ticket by its ID.get_tickets(): Retrieves all tickets.get_open_tickets(): Retrieves only open tickets.
-
Users:
get_user(user_id: int): Retrieves a specific user by their ID.get_users(): Retrieves all users.
Environment Variables
To configure the connection to the GLPI API, create a .env file in the project root directory with the following variables:
GLPI_BASE_URL='GLPI_BASE_URL'
GLPI_USER_TOKEN='GLPI_USER_TOKEN'
GLPI_TICKET_STATUS=[1, 2, 3, 4]
GLPI_BASE_URL: The base URL for the GLPI API.GLPI_USER_TOKEN: The user token for authenticating API requests.GLPI_TICKET_STATUS: A list of ticket statuses to filter tickets when calling methods like get_open_tickets().
Usage Example
Below is an example of how to use the abstraction layer to retrieve open tickets:
from glpi_provider import GlpiProvider
# Initialize the GLPI provider and create a session
provider = GlpiProvider()
provider.create_session()
# Retrieve and print the list of open tickets
tickets = provider.get_open_tickets()
print(tickets)
# Close the session with the API
provider.close_session()
Metadata
Release files for glpi-provider 0.3.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| glpi_provider-0.3.9-py3-none-any.whl | Python 3 | none | any | Details for glpi_provider-0.3.9-py3-none-any.whl |
Release files / glpi_provider-0.3.9-py3-none-any.whl
| Download URL | glpi_provider-0.3.9-py3-none-any.whl |
|---|---|
| Size | 31.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9e69bf3743df63289cf4e14ffe9279cab5ca5a0a8ed126cb6bf184c2a8c081d4
|
|
BLAKE2b-256 checksum How to use checksums |
1b57f41ad71d7064122732143881d48808f832d9aa551ddff4f47aa46f993cc9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for glpi-provider 0.3.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.