Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ All notable changes to this project are documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## 0.6.9 — 2026-11-10

A fix for GLPI 12. GLPI 12.0.1 sends a ticket's `ola_ttr` and `ola_tto` as an
empty array, `[]`, when the ticket has no OLA. Its own v2.3 contract, like
GLPI 11, declares a nullable object there. `GetTicket` refused the array, so
every ticket read and every ticket search raised `ValidationError` against a
GLPI 12 server.

### Fixed

- **All six SLA and OLA references of `GetTicket`** (`sla_ttr`, `sla_tto`,
`sla_level_ttr`, `ola_ttr`, `ola_tto`, `ola_level_ttr`) read an empty array as
`None`. An object and `null` read as before. Nothing else changes.

## 0.6.8 — 2026-11-02

A minor addition: a way to write or clear a ticket's take-into-account stamp,
Expand Down
2 changes: 1 addition & 1 deletion glpi_python_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
date_window,
)

__version__ = "0.6.8"
__version__ = "0.6.9"

__all__ = [
"AsyncGlpiClient",
Expand Down
37 changes: 30 additions & 7 deletions glpi_python_client/models/api_schema/assistance/_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

from datetime import datetime
from functools import cached_property
from typing import Annotated

from pydantic import BeforeValidator

from glpi_python_client.models._base import GlpiModel
from glpi_python_client.models.api_schema._common import (
Expand All @@ -41,6 +44,24 @@
)


def _empty_list_as_none(value: object) -> object:
"""Read an empty JSON array as an absent reference.

GLPI 12 sends ``ola_ttr`` and ``ola_tto`` as ``[]`` on a ticket with no
OLA, where its own v2.3 contract, like GLPI 11, declares a nullable
``{"id", "name"}`` object. Every SLA and OLA reference of
:class:`GetTicket` reads through this, so the same quirk on any of them
cannot fail a ticket read. Every other value is passed on unchanged.
"""

if isinstance(value, list) and not value:
return None
return value


_LevelAgreementRef = Annotated[IdNameRef | None, BeforeValidator(_empty_list_as_none)]


class _TicketTeamMember(GlpiModel):
"""One inline team-member entry of the ``Ticket.team`` array.

Expand Down Expand Up @@ -158,7 +179,9 @@ class GetTicket(GlpiModel):
sla_level_ttr : IdNameRef | None, optional
SLA level escalation step for time-to-resolve.
ola_level_ttr : IdNameRef | None, optional
OLA level escalation step for time-to-resolve.
OLA level escalation step for time-to-resolve. On all six SLA and
OLA references an empty array reads as :data:`None`: GLPI 12 sends
``[]`` for ``ola_ttr`` and ``ola_tto`` on a ticket with no OLA.
sla_waiting_duration : int | None, optional
Total SLA waiting duration in seconds (contract field
``sla_waiting_duration`` — ``Total SLA waiting duration in
Expand Down Expand Up @@ -217,12 +240,12 @@ class GetTicket(GlpiModel):
request_type: IdNameRef | None = None
take_into_account_date: datetime | None = None
take_into_account_duration: int | None = None
sla_ttr: IdNameRef | None = None
sla_tto: IdNameRef | None = None
ola_ttr: IdNameRef | None = None
ola_tto: IdNameRef | None = None
sla_level_ttr: IdNameRef | None = None
ola_level_ttr: IdNameRef | None = None
sla_ttr: _LevelAgreementRef = None
sla_tto: _LevelAgreementRef = None
ola_ttr: _LevelAgreementRef = None
ola_tto: _LevelAgreementRef = None
sla_level_ttr: _LevelAgreementRef = None
ola_level_ttr: _LevelAgreementRef = None
sla_waiting_duration: int | None = None
ola_waiting_duration: int | None = None
ola_ttr_begin_date: datetime | None = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,61 @@ def test_get_ticket_accepts_the_major_priority_level() -> None:
assert ticket.priority.glpi_id == 6


_LEVEL_AGREEMENT_FIELDS = (
"sla_ttr",
"sla_tto",
"ola_ttr",
"ola_tto",
"sla_level_ttr",
"ola_level_ttr",
)


@pytest.mark.parametrize("field", _LEVEL_AGREEMENT_FIELDS)
def test_get_ticket_reads_an_empty_sla_or_ola_array_as_none(field: str) -> None:
"""GLPI 12's ``[]`` for a missing SLA or OLA reads as none.

GLPI 12.0.1 sends ``ola_ttr`` and ``ola_tto`` as an empty array on every
ticket without an OLA, where its v2.3 contract and GLPI 11 give a
nullable object. ``GetTicket`` used to raise ``ValidationError`` on it,
which failed every ticket read and every search against such a server.
All six SLA and OLA references read the same way.
"""

ticket = GetTicket.model_validate({"id": 1, field: []})
assert getattr(ticket, field) is None


@pytest.mark.parametrize("field", _LEVEL_AGREEMENT_FIELDS)
def test_get_ticket_still_reads_an_sla_or_ola_object_and_null(field: str) -> None:
"""The contract's own shapes, an object and ``null``, are unchanged."""

ticket = GetTicket.model_validate({"id": 1, field: {"id": 3, "name": "8h"}})
ref = getattr(ticket, field)
assert ref is not None
assert (ref.id, ref.name) == (3, "8h")
assert getattr(GetTicket.model_validate({"id": 1, field: None}), field) is None


def test_get_ticket_reads_a_glpi_12_ticket_with_an_sla_and_no_ola() -> None:
"""The shape GLPI 12 sends for a ticket with an SLA and no OLA."""

ticket = GetTicket.model_validate(
{
"id": 1,
"sla_ttr": {"id": 5, "name": "TTR 4h"},
"sla_tto": {"id": 6, "name": "TTO 1h"},
"sla_level_ttr": None,
"ola_ttr": [],
"ola_tto": [],
"ola_level_ttr": None,
}
)
assert ticket.sla_ttr is not None and ticket.sla_ttr.id == 5
assert ticket.sla_tto is not None and ticket.sla_tto.id == 6
assert ticket.ola_ttr is None and ticket.ola_tto is None


def test_urgency_and_impact_still_span_one_to_five() -> None:
"""The five contract-declared levels keep their identifiers.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ exclude = [

[project]
name = "glpi-python-client"
version = "0.6.8"
version = "0.6.9"
description = "A typed Python client for GLPI ITSM APIs."
readme = "README.md"
requires-python = ">=3.11"
Expand Down
2 changes: 1 addition & 1 deletion skills/glpi-asset-workflow/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license: MIT
compatibility: "Requires Python 3.11+, glpi-python-client, network access to the GLPI v2 API, and credentials allowed to read or write assets."
metadata:
package: glpi-python-client
version: "0.6.8"
version: "0.6.9"
---

# GLPI Asset Workflow
Expand Down
2 changes: 1 addition & 1 deletion skills/glpi-client-setup/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license: MIT
compatibility: "Requires Python 3.11+, glpi-python-client, network access to a GLPI v2 API, and valid GLPI credentials."
metadata:
package: glpi-python-client
version: "0.6.8"
version: "0.6.9"
---

# GLPI Client Setup
Expand Down
2 changes: 1 addition & 1 deletion skills/glpi-contract-workflow/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license: MIT
compatibility: "Requires Python 3.11+, glpi-python-client, network access to the GLPI v2 API, and credentials allowed to read or write contracts."
metadata:
package: glpi-python-client
version: "0.6.8"
version: "0.6.9"
---

# GLPI Contract Workflow
Expand Down
2 changes: 1 addition & 1 deletion skills/glpi-document-workflow/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license: MIT
compatibility: "Requires Python 3.11+, glpi-python-client, network access to the GLPI v2 API, and v1 credentials configured on the client for binary uploads."
metadata:
package: glpi-python-client
version: "0.6.8"
version: "0.6.9"
---

# GLPI Document Workflow
Expand Down
2 changes: 1 addition & 1 deletion skills/glpi-knowledge-base/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license: MIT
compatibility: "Requires Python 3.11+, glpi-python-client, network access to the GLPI v2 API, and — for category writes only — a legacy v1 session (v1_base_url + v1_user_token)."
metadata:
package: glpi-python-client
version: "0.6.8"
version: "0.6.9"
---

# GLPI Knowledge Base
Expand Down
2 changes: 1 addition & 1 deletion skills/glpi-plugin-fields/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license: MIT
compatibility: "Requires Python 3.11+, glpi-python-client, the GLPI Fields plugin installed server-side, and a legacy v1 session (v1_base_url + v1_user_token) — every method in this family goes over the v1 API."
metadata:
package: glpi-python-client
version: "0.6.8"
version: "0.6.9"
---

# GLPI Plugin Fields
Expand Down
2 changes: 1 addition & 1 deletion skills/glpi-reporting-and-context/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license: MIT
compatibility: "Requires Python 3.11+, glpi-python-client, network access to the GLPI v2 API, and credentials allowed to read tickets, tasks, users, entities, and timeline records."
metadata:
package: glpi-python-client
version: "0.6.8"
version: "0.6.9"
---

# GLPI Reporting And Context
Expand Down
2 changes: 1 addition & 1 deletion skills/glpi-team-members/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license: MIT
compatibility: "Requires Python 3.11+, glpi-python-client, network access to the GLPI v2 API, and credentials allowed to manage ticket teams."
metadata:
package: glpi-python-client
version: "0.6.8"
version: "0.6.9"
---

# GLPI Team Members
Expand Down
2 changes: 1 addition & 1 deletion skills/glpi-ticket-timeline/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license: MIT
compatibility: "Requires Python 3.11+, glpi-python-client, and network access to the GLPI v2 API."
metadata:
package: glpi-python-client
version: "0.6.8"
version: "0.6.9"
---

# GLPI Ticket Timeline
Expand Down
2 changes: 1 addition & 1 deletion skills/glpi-ticket-workflow/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license: MIT
compatibility: "Requires Python 3.11+, glpi-python-client, network access to the GLPI v2 API, and credentials accepted by GlpiClient."
metadata:
package: glpi-python-client
version: "0.6.8"
version: "0.6.9"
---

# GLPI Ticket Workflow
Expand Down
2 changes: 1 addition & 1 deletion skills/glpi-user-location-provisioning/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license: MIT
compatibility: "Requires Python 3.11+, glpi-python-client, network access to the GLPI v2 API, and credentials allowed to read or write users, locations, and entities."
metadata:
package: glpi-python-client
version: "0.6.8"
version: "0.6.9"
---

# GLPI User, Location, And Entity Provisioning
Expand Down
Loading