Skip to content

Latest commit

 

History

History
92 lines (70 loc) · 2.94 KB

File metadata and controls

92 lines (70 loc) · 2.94 KB

glpi-python-client

CI 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 matching sync and async high-level clients.

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 API URL and at least one complete auth pair:

  • client_id and client_secret
  • username and password
  • both pairs together
from glpi_python_client import GlpiClient, GlpiTicket

with GlpiClient(
    glpi_api_url="https://glpi.example.com/api.php",
    client_id="oauth-client-id",
    client_secret="oauth-client-secret",
    username="api-user",
    password="api-password",
) as glpi:
    ticket_id = glpi.create_ticket(
        GlpiTicket(
            name="Printer issue",
            content="The printer is not reachable from the office network.",
            urgency=3,
            impact=3,
        )
    )
    ticket = glpi.get_ticket_record(ticket_id)

    print(ticket.id)
    print(ticket.content)

Async code uses the same model layer and nearly the same API surface:

from glpi_python_client import AsyncGlpiClient

async with AsyncGlpiClient(
    glpi_api_url="https://glpi.example.com/api.php",
    client_id="oauth-client-id",
    client_secret="oauth-client-secret",
) as glpi:
    tickets = await glpi.search_ticket_records(query='status.id=in=(1,2)')

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

Documentation

To build the Sphinx documentation locally:

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