Skip to main content

A typed Python client for GLPI ITSM APIs.

Project description

glpi-python-client

CI Coverage License Python Docs

glpi-python-client is a typed Python client for GLPI ITSM APIs.

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 a single asynchronous high-level client built on top of the GLPI v2 REST API.

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_id and client_secret
  • username and password
  • both pairs together
import asyncio

from glpi_python_client import GlpiClient, PostTicket


async def main() -> None:
    async 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 = 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())

If your application already provides GLPI_ environment variables, GlpiClient.from_env() is also available.

Calling from synchronous code

The client is async-only, but it works from sync programs through asyncio.run. Wrap the calls in a coroutine and execute it once:

import asyncio

from glpi_python_client import GlpiClient


def fetch_open_tickets() -> list[int]:
    async def _run() -> list[int]:
        async with GlpiClient.from_env() as glpi:
            tickets = await glpi.search_tickets("status==1", limit=10)
            return [ticket.id for ticket in tickets]

    return asyncio.run(_run())


if __name__ == "__main__":
    print(fetch_open_tickets())

For long-lived sync services that need many calls, run a dedicated event loop on a background thread and dispatch with asyncio.run_coroutine_threadsafe. See the user guide for the full pattern.

Documentation

To build the Sphinx documentation locally:

python -m pip install -e .[docs]
python -m sphinx -b html docs docs/_build/html

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glpi_python_client-0.2.1.tar.gz (221.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

glpi_python_client-0.2.1-py3-none-any.whl (112.6 kB view details)

Uploaded Python 3

File details

Details for the file glpi_python_client-0.2.1.tar.gz.

File metadata

  • Download URL: glpi_python_client-0.2.1.tar.gz
  • Upload date:
  • Size: 221.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for glpi_python_client-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ea7aff5da186fd24bfd28562172001835ba0099b0203aae330351ef47b07337c
MD5 d9e548f8dd25e01d957ae493120174d4
BLAKE2b-256 69ec58919e2231b8425226a0f8650c929430a67e8d15a324e33c9617cc54e973

See more details on using hashes here.

Provenance

The following attestation bundles were made for glpi_python_client-0.2.1.tar.gz:

Publisher: release.yml on baraline/glpi_python_client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file glpi_python_client-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for glpi_python_client-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 165b5c1ac6a7e7f6c7a8c0c5a233503bd27397e5a1e29c54fd19c1ef06ae1317
MD5 c373b66cfe103f7a90f42d54f43db860
BLAKE2b-256 e0fa9e9ceeb322bbc51a0fefc7366d6db5d27f28830f12cadbd0568305487253

See more details on using hashes here.

Provenance

The following attestation bundles were made for glpi_python_client-0.2.1-py3-none-any.whl:

Publisher: release.yml on baraline/glpi_python_client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page