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.0.tar.gz (215.2 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.0-py3-none-any.whl (109.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: glpi_python_client-0.2.0.tar.gz
  • Upload date:
  • Size: 215.2 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.0.tar.gz
Algorithm Hash digest
SHA256 20d6794836219674a0dafa6411a71c9230443d2d6f8dd480fb5fc2fd961eb468
MD5 724fb17feab3f5c4e80e279c00b81d76
BLAKE2b-256 2dbf24f64c7f5d5ffa15f4f37d8daa8d0f883468f60ddac5126cf9d5229abba6

See more details on using hashes here.

Provenance

The following attestation bundles were made for glpi_python_client-0.2.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for glpi_python_client-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c17ab981898364a6e6500e4fa4363dae371e1f4e22643dede461ab961c603fb3
MD5 575ffaf6ef09147240259c51d3dfac01
BLAKE2b-256 b972e22133cec695c842bf8fe8e0e71e306bd370ef1ee44a8f1d7ad8e5f06f99

See more details on using hashes here.

Provenance

The following attestation bundles were made for glpi_python_client-0.2.0-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