A typed Python client for GLPI ITSM APIs.
Project description
glpi-python-client
glpi-python-client is a typed Python client for the GLPI REST API.
The goal is to let GLPI integrations work with domain objects instead of raw JSON payloads. The package exposes Pydantic models for tickets, users, followups, documents, locations, and related records, while converting GLPI HTML content into Markdown for Python-side workflows and rendering Markdown back to HTML for outgoing payloads.
It currently focuses on ticket-centric workflows and exposes two high-level clients built on top of the GLPI v2 REST API:
GlpiClient— synchronous, blocking client (single source of truth for endpoint behaviour).AsyncGlpiClient— asynchronous facade that wraps every synchronous method into a coroutine and dispatches it to a worker thread.
Note that all integration tests using this package are made on GLPI 11. I cannot make any guarantee of the behaviour on previous versions.
While the package is preparing for 1.0, alot of potential breaking change might happen between versions. A deprecation policy will be put in place once 1.0 is out and the package have been stabilized.
Installation
pip install glpi-python-client
For local development:
python -m pip install -e .[dev]
python -m pytest
Quick Start
Create a client with your GLPI v2 API URL and at least one complete auth pair:
client_idandclient_secretusernameandpassword- both pairs together
Synchronous client
from glpi_python_client import GlpiClient, PostTicket
with GlpiClient(
glpi_api_url="https://glpi.example.com/api.php/v2",
client_id="oauth-client-id",
client_secret="oauth-client-secret",
username="api-user",
password="api-password",
) as glpi:
ticket_id = glpi.create_ticket(
PostTicket(
name="Printer issue",
content="The printer is not reachable from the office network.",
)
)
ticket = glpi.get_ticket(ticket_id)
print(ticket.id, ticket.name)
Asynchronous client
import asyncio
from glpi_python_client import AsyncGlpiClient, PostTicket
async def main() -> None:
async with AsyncGlpiClient(
glpi_api_url="https://glpi.example.com/api.php/v2",
client_id="oauth-client-id",
client_secret="oauth-client-secret",
username="api-user",
password="api-password",
) as glpi:
ticket_id = await glpi.create_ticket(
PostTicket(
name="Printer issue",
content="The printer is not reachable from the office network.",
)
)
ticket = await glpi.get_ticket(ticket_id)
print(ticket.id, ticket.name)
asyncio.run(main())
GlpiClient.from_env() and AsyncGlpiClient.from_env() are also available
when the credentials are already exposed as GLPI_-prefixed environment
variables.
Sync or async?
Both clients expose the exact same endpoint surface and accept the same
constructor arguments. The async client is a thin facade that wraps each
synchronous method into a coroutine dispatched to a worker thread via
asyncio.to_thread (or a caller-supplied concurrent.futures.Executor).
A shared threading.Lock serialises OAuth token acquisition so concurrent
asyncio.gather(...) fan-outs cannot race. Pick GlpiClient for plain
scripts, CLI tools, and synchronous services; pick AsyncGlpiClient when
your application already runs an event loop or when you need concurrent
fan-out (the aggregated get_ticket_context and per-ticket
get_task_statistics helpers use asyncio.gather on the async client).
Documentation
To build the Sphinx documentation locally:
python -m pip install -e .[docs]
python -m sphinx -b html docs docs/_build/html
Sponsoring & Professional services
The development of this package is indirectly supported by Novahé & Constellation.
If you need professional help or services around GLPI, we offer consulting and engineering services to install, maintain or upgarde GLPI instance, as an official GLPI partner.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file glpi_python_client-0.3.2.tar.gz.
File metadata
- Download URL: glpi_python_client-0.3.2.tar.gz
- Upload date:
- Size: 251.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09131a43d27f6d2291819dc576d735ea8cff046708550eaaae8ba8886ab369c6
|
|
| MD5 |
e8cc28fd9fc69ca801f93f866a98cddc
|
|
| BLAKE2b-256 |
ac6316aa50cf950a7159c2788c35cb4bc3b52cd7cbdd80f199aafc9640e02764
|
Provenance
The following attestation bundles were made for glpi_python_client-0.3.2.tar.gz:
Publisher:
release.yml on baraline/glpi_python_client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
glpi_python_client-0.3.2.tar.gz -
Subject digest:
09131a43d27f6d2291819dc576d735ea8cff046708550eaaae8ba8886ab369c6 - Sigstore transparency entry: 1567509803
- Sigstore integration time:
-
Permalink:
baraline/glpi_python_client@598ca3d6d76bae28f1d2775f7a2d65e918d277ae -
Branch / Tag:
refs/tags/0.3.2 - Owner: https://github.com/baraline
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@598ca3d6d76bae28f1d2775f7a2d65e918d277ae -
Trigger Event:
release
-
Statement type:
File details
Details for the file glpi_python_client-0.3.2-py3-none-any.whl.
File metadata
- Download URL: glpi_python_client-0.3.2-py3-none-any.whl
- Upload date:
- Size: 155.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeeb149c5b6553ccde9b0f32e1a40aafdd80943e642f61b2d33e57e597cd9500
|
|
| MD5 |
fa470ae336e94f75b03926705f560e4c
|
|
| BLAKE2b-256 |
0154c3ca34f657edceb623a9beb18c01082834773528a94ca07ff8e5758438a2
|
Provenance
The following attestation bundles were made for glpi_python_client-0.3.2-py3-none-any.whl:
Publisher:
release.yml on baraline/glpi_python_client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
glpi_python_client-0.3.2-py3-none-any.whl -
Subject digest:
aeeb149c5b6553ccde9b0f32e1a40aafdd80943e642f61b2d33e57e597cd9500 - Sigstore transparency entry: 1567509854
- Sigstore integration time:
-
Permalink:
baraline/glpi_python_client@598ca3d6d76bae28f1d2775f7a2d65e918d277ae -
Branch / Tag:
refs/tags/0.3.2 - Owner: https://github.com/baraline
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@598ca3d6d76bae28f1d2775f7a2d65e918d277ae -
Trigger Event:
release
-
Statement type: