glpi-python-client 0.6.7__py3-none-any.whl → 0.6.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- glpi_python_client/__init__.py +1 -1
- glpi_python_client/_async/clients/api/assistance/_ticket.py +132 -0
- glpi_python_client/_sync/clients/api/assistance/_ticket.py +132 -0
- {glpi_python_client-0.6.7.dist-info → glpi_python_client-0.6.8.dist-info}/METADATA +1 -1
- {glpi_python_client-0.6.7.dist-info → glpi_python_client-0.6.8.dist-info}/RECORD +7 -7
- {glpi_python_client-0.6.7.dist-info → glpi_python_client-0.6.8.dist-info}/WHEEL +0 -0
- {glpi_python_client-0.6.7.dist-info → glpi_python_client-0.6.8.dist-info}/licenses/LICENSE +0 -0
glpi_python_client/__init__.py
CHANGED
|
@@ -7,8 +7,12 @@ GLPI ticket resource using the ``api_schema`` Pydantic models.
|
|
|
7
7
|
from __future__ import annotations
|
|
8
8
|
|
|
9
9
|
from collections.abc import AsyncIterator
|
|
10
|
+
from datetime import datetime
|
|
10
11
|
|
|
11
12
|
from glpi_python_client._async.clients.commons._constants import TICKET_ENDPOINT, GlpiId
|
|
13
|
+
from glpi_python_client._async.clients.commons._payloads import (
|
|
14
|
+
ensure_v1_write_accepted,
|
|
15
|
+
)
|
|
12
16
|
from glpi_python_client._async.clients.commons._transport import TransportMixin
|
|
13
17
|
from glpi_python_client.models.api_schema.assistance._ticket import (
|
|
14
18
|
DeleteTicket,
|
|
@@ -17,6 +21,8 @@ from glpi_python_client.models.api_schema.assistance._ticket import (
|
|
|
17
21
|
PostTicket,
|
|
18
22
|
)
|
|
19
23
|
|
|
24
|
+
_V1_TICKET_FEATURE_LABEL = "take-into-account writes"
|
|
25
|
+
|
|
20
26
|
|
|
21
27
|
class TicketMixin(TransportMixin):
|
|
22
28
|
"""CRUD helpers for ``/Assistance/Ticket``.
|
|
@@ -240,5 +246,131 @@ class TicketMixin(TransportMixin):
|
|
|
240
246
|
delete_model_cls=DeleteTicket,
|
|
241
247
|
)
|
|
242
248
|
|
|
249
|
+
async def change_ticket_take_into_account(
|
|
250
|
+
self,
|
|
251
|
+
ticket_id: GlpiId,
|
|
252
|
+
*,
|
|
253
|
+
take_into_account_date: datetime | None,
|
|
254
|
+
take_into_account_duration: int,
|
|
255
|
+
do_not_compute: bool = True,
|
|
256
|
+
disable_notifications: bool = True,
|
|
257
|
+
) -> None:
|
|
258
|
+
"""Write the take-into-account stamp of one ticket.
|
|
259
|
+
|
|
260
|
+
GLPI stamps ``take_into_account_date`` on the first write made by an
|
|
261
|
+
account allowed to take a ticket into account (and when a group is
|
|
262
|
+
assigned). The v2 ``Ticket`` schema exposes the date as read-only and
|
|
263
|
+
silently ignores ``_do_not_compute_takeintoaccount``, so the write
|
|
264
|
+
goes through the legacy v1 API, which requires
|
|
265
|
+
``v1_base_url``/``v1_user_token`` to be configured (pointing at the
|
|
266
|
+
legacy ``apirest.php``). GLPI records the change in the ticket
|
|
267
|
+
history either way.
|
|
268
|
+
|
|
269
|
+
Parameters
|
|
270
|
+
----------
|
|
271
|
+
ticket_id : int | str
|
|
272
|
+
Identifier of the ticket.
|
|
273
|
+
take_into_account_date : datetime | None
|
|
274
|
+
New take-into-account instant (v1 ``takeintoaccountdate``), or
|
|
275
|
+
``None`` for no stamp. An aware value is converted to the
|
|
276
|
+
server's clock; a naive one is taken to be on it already. GLPI
|
|
277
|
+
writes ``null`` instead whenever the duration is ``0``.
|
|
278
|
+
take_into_account_duration : int
|
|
279
|
+
Seconds from creation to the take-into-account (v1
|
|
280
|
+
``takeintoaccount_delay_stat``). GLPI treats ``0`` as "not taken
|
|
281
|
+
into account".
|
|
282
|
+
do_not_compute : bool, optional
|
|
283
|
+
``True`` (the default) sends ``_do_not_compute_takeintoaccount``
|
|
284
|
+
so GLPI keeps the values written. With ``False`` and a zero
|
|
285
|
+
duration, an account allowed to take the ticket into account
|
|
286
|
+
stamps it again with the current time in the same write.
|
|
287
|
+
disable_notifications : bool, optional
|
|
288
|
+
``True`` (the default) sends ``_disablenotif``, which suppresses
|
|
289
|
+
the "ticket updated" notification.
|
|
290
|
+
|
|
291
|
+
Raises
|
|
292
|
+
------
|
|
293
|
+
RuntimeError
|
|
294
|
+
When no legacy v1 session is configured on the client.
|
|
295
|
+
GlpiStatusError
|
|
296
|
+
When the legacy API returns a non-success status.
|
|
297
|
+
GlpiProtocolError
|
|
298
|
+
When the legacy API answers that the update was refused.
|
|
299
|
+
"""
|
|
300
|
+
|
|
301
|
+
v1 = self._require_v1_session(_V1_TICKET_FEATURE_LABEL)
|
|
302
|
+
stamp: str | None = None
|
|
303
|
+
if take_into_account_date is not None:
|
|
304
|
+
if take_into_account_date.tzinfo is not None:
|
|
305
|
+
take_into_account_date = take_into_account_date.astimezone(
|
|
306
|
+
self.server_timezone
|
|
307
|
+
)
|
|
308
|
+
stamp = take_into_account_date.strftime("%Y-%m-%d %H:%M:%S")
|
|
309
|
+
update: dict[str, object] = {
|
|
310
|
+
"id": int(ticket_id),
|
|
311
|
+
"takeintoaccountdate": stamp,
|
|
312
|
+
"takeintoaccount_delay_stat": take_into_account_duration,
|
|
313
|
+
}
|
|
314
|
+
# GLPI reads ``_disablenotif`` with isset(), so a False flag must be absent.
|
|
315
|
+
if do_not_compute:
|
|
316
|
+
update["_do_not_compute_takeintoaccount"] = True
|
|
317
|
+
if disable_notifications:
|
|
318
|
+
update["_disablenotif"] = True
|
|
319
|
+
payload = await v1.request_json(
|
|
320
|
+
"PUT",
|
|
321
|
+
f"Ticket/{ticket_id}",
|
|
322
|
+
json_body={"input": update},
|
|
323
|
+
failure_message=(
|
|
324
|
+
f"Failed to write the take-into-account stamp of ticket {ticket_id}"
|
|
325
|
+
),
|
|
326
|
+
)
|
|
327
|
+
ensure_v1_write_accepted(
|
|
328
|
+
payload, f"Writing the take-into-account stamp of ticket {ticket_id}"
|
|
329
|
+
)
|
|
330
|
+
|
|
331
|
+
async def clear_ticket_take_into_account(
|
|
332
|
+
self,
|
|
333
|
+
ticket_id: GlpiId,
|
|
334
|
+
*,
|
|
335
|
+
do_not_compute: bool = True,
|
|
336
|
+
disable_notifications: bool = True,
|
|
337
|
+
) -> None:
|
|
338
|
+
"""Clear the take-into-account stamp of one ticket.
|
|
339
|
+
|
|
340
|
+
The stamp collapses the time-to-own statistic to nearly zero for a
|
|
341
|
+
ticket a connector has just created and written to. This is
|
|
342
|
+
:meth:`change_ticket_take_into_account` with a ``None`` date and a
|
|
343
|
+
``0`` duration, so it has the same v1 requirement.
|
|
344
|
+
|
|
345
|
+
Parameters
|
|
346
|
+
----------
|
|
347
|
+
ticket_id : int | str
|
|
348
|
+
Identifier of the ticket.
|
|
349
|
+
do_not_compute : bool, optional
|
|
350
|
+
``True`` (the default) keeps GLPI from stamping the ticket again
|
|
351
|
+
in the same write. ``False`` lets an account allowed to take the
|
|
352
|
+
ticket into account undo the clear at once.
|
|
353
|
+
disable_notifications : bool, optional
|
|
354
|
+
``True`` (the default) suppresses the "ticket updated"
|
|
355
|
+
notification.
|
|
356
|
+
|
|
357
|
+
Raises
|
|
358
|
+
------
|
|
359
|
+
RuntimeError
|
|
360
|
+
When no legacy v1 session is configured on the client.
|
|
361
|
+
GlpiStatusError
|
|
362
|
+
When the legacy API returns a non-success status.
|
|
363
|
+
GlpiProtocolError
|
|
364
|
+
When the legacy API answers that the update was refused.
|
|
365
|
+
"""
|
|
366
|
+
|
|
367
|
+
await self.change_ticket_take_into_account(
|
|
368
|
+
ticket_id,
|
|
369
|
+
take_into_account_date=None,
|
|
370
|
+
take_into_account_duration=0,
|
|
371
|
+
do_not_compute=do_not_compute,
|
|
372
|
+
disable_notifications=disable_notifications,
|
|
373
|
+
)
|
|
374
|
+
|
|
243
375
|
|
|
244
376
|
__all__ = ["TicketMixin"]
|
|
@@ -7,8 +7,12 @@ GLPI ticket resource using the ``api_schema`` Pydantic models.
|
|
|
7
7
|
from __future__ import annotations
|
|
8
8
|
|
|
9
9
|
from collections.abc import Iterator
|
|
10
|
+
from datetime import datetime
|
|
10
11
|
|
|
11
12
|
from glpi_python_client._sync.clients.commons._constants import TICKET_ENDPOINT, GlpiId
|
|
13
|
+
from glpi_python_client._sync.clients.commons._payloads import (
|
|
14
|
+
ensure_v1_write_accepted,
|
|
15
|
+
)
|
|
12
16
|
from glpi_python_client._sync.clients.commons._transport import TransportMixin
|
|
13
17
|
from glpi_python_client.models.api_schema.assistance._ticket import (
|
|
14
18
|
DeleteTicket,
|
|
@@ -17,6 +21,8 @@ from glpi_python_client.models.api_schema.assistance._ticket import (
|
|
|
17
21
|
PostTicket,
|
|
18
22
|
)
|
|
19
23
|
|
|
24
|
+
_V1_TICKET_FEATURE_LABEL = "take-into-account writes"
|
|
25
|
+
|
|
20
26
|
|
|
21
27
|
class TicketMixin(TransportMixin):
|
|
22
28
|
"""CRUD helpers for ``/Assistance/Ticket``.
|
|
@@ -240,5 +246,131 @@ class TicketMixin(TransportMixin):
|
|
|
240
246
|
delete_model_cls=DeleteTicket,
|
|
241
247
|
)
|
|
242
248
|
|
|
249
|
+
def change_ticket_take_into_account(
|
|
250
|
+
self,
|
|
251
|
+
ticket_id: GlpiId,
|
|
252
|
+
*,
|
|
253
|
+
take_into_account_date: datetime | None,
|
|
254
|
+
take_into_account_duration: int,
|
|
255
|
+
do_not_compute: bool = True,
|
|
256
|
+
disable_notifications: bool = True,
|
|
257
|
+
) -> None:
|
|
258
|
+
"""Write the take-into-account stamp of one ticket.
|
|
259
|
+
|
|
260
|
+
GLPI stamps ``take_into_account_date`` on the first write made by an
|
|
261
|
+
account allowed to take a ticket into account (and when a group is
|
|
262
|
+
assigned). The v2 ``Ticket`` schema exposes the date as read-only and
|
|
263
|
+
silently ignores ``_do_not_compute_takeintoaccount``, so the write
|
|
264
|
+
goes through the legacy v1 API, which requires
|
|
265
|
+
``v1_base_url``/``v1_user_token`` to be configured (pointing at the
|
|
266
|
+
legacy ``apirest.php``). GLPI records the change in the ticket
|
|
267
|
+
history either way.
|
|
268
|
+
|
|
269
|
+
Parameters
|
|
270
|
+
----------
|
|
271
|
+
ticket_id : int | str
|
|
272
|
+
Identifier of the ticket.
|
|
273
|
+
take_into_account_date : datetime | None
|
|
274
|
+
New take-into-account instant (v1 ``takeintoaccountdate``), or
|
|
275
|
+
``None`` for no stamp. An aware value is converted to the
|
|
276
|
+
server's clock; a naive one is taken to be on it already. GLPI
|
|
277
|
+
writes ``null`` instead whenever the duration is ``0``.
|
|
278
|
+
take_into_account_duration : int
|
|
279
|
+
Seconds from creation to the take-into-account (v1
|
|
280
|
+
``takeintoaccount_delay_stat``). GLPI treats ``0`` as "not taken
|
|
281
|
+
into account".
|
|
282
|
+
do_not_compute : bool, optional
|
|
283
|
+
``True`` (the default) sends ``_do_not_compute_takeintoaccount``
|
|
284
|
+
so GLPI keeps the values written. With ``False`` and a zero
|
|
285
|
+
duration, an account allowed to take the ticket into account
|
|
286
|
+
stamps it again with the current time in the same write.
|
|
287
|
+
disable_notifications : bool, optional
|
|
288
|
+
``True`` (the default) sends ``_disablenotif``, which suppresses
|
|
289
|
+
the "ticket updated" notification.
|
|
290
|
+
|
|
291
|
+
Raises
|
|
292
|
+
------
|
|
293
|
+
RuntimeError
|
|
294
|
+
When no legacy v1 session is configured on the client.
|
|
295
|
+
GlpiStatusError
|
|
296
|
+
When the legacy API returns a non-success status.
|
|
297
|
+
GlpiProtocolError
|
|
298
|
+
When the legacy API answers that the update was refused.
|
|
299
|
+
"""
|
|
300
|
+
|
|
301
|
+
v1 = self._require_v1_session(_V1_TICKET_FEATURE_LABEL)
|
|
302
|
+
stamp: str | None = None
|
|
303
|
+
if take_into_account_date is not None:
|
|
304
|
+
if take_into_account_date.tzinfo is not None:
|
|
305
|
+
take_into_account_date = take_into_account_date.astimezone(
|
|
306
|
+
self.server_timezone
|
|
307
|
+
)
|
|
308
|
+
stamp = take_into_account_date.strftime("%Y-%m-%d %H:%M:%S")
|
|
309
|
+
update: dict[str, object] = {
|
|
310
|
+
"id": int(ticket_id),
|
|
311
|
+
"takeintoaccountdate": stamp,
|
|
312
|
+
"takeintoaccount_delay_stat": take_into_account_duration,
|
|
313
|
+
}
|
|
314
|
+
# GLPI reads ``_disablenotif`` with isset(), so a False flag must be absent.
|
|
315
|
+
if do_not_compute:
|
|
316
|
+
update["_do_not_compute_takeintoaccount"] = True
|
|
317
|
+
if disable_notifications:
|
|
318
|
+
update["_disablenotif"] = True
|
|
319
|
+
payload = v1.request_json(
|
|
320
|
+
"PUT",
|
|
321
|
+
f"Ticket/{ticket_id}",
|
|
322
|
+
json_body={"input": update},
|
|
323
|
+
failure_message=(
|
|
324
|
+
f"Failed to write the take-into-account stamp of ticket {ticket_id}"
|
|
325
|
+
),
|
|
326
|
+
)
|
|
327
|
+
ensure_v1_write_accepted(
|
|
328
|
+
payload, f"Writing the take-into-account stamp of ticket {ticket_id}"
|
|
329
|
+
)
|
|
330
|
+
|
|
331
|
+
def clear_ticket_take_into_account(
|
|
332
|
+
self,
|
|
333
|
+
ticket_id: GlpiId,
|
|
334
|
+
*,
|
|
335
|
+
do_not_compute: bool = True,
|
|
336
|
+
disable_notifications: bool = True,
|
|
337
|
+
) -> None:
|
|
338
|
+
"""Clear the take-into-account stamp of one ticket.
|
|
339
|
+
|
|
340
|
+
The stamp collapses the time-to-own statistic to nearly zero for a
|
|
341
|
+
ticket a connector has just created and written to. This is
|
|
342
|
+
:meth:`change_ticket_take_into_account` with a ``None`` date and a
|
|
343
|
+
``0`` duration, so it has the same v1 requirement.
|
|
344
|
+
|
|
345
|
+
Parameters
|
|
346
|
+
----------
|
|
347
|
+
ticket_id : int | str
|
|
348
|
+
Identifier of the ticket.
|
|
349
|
+
do_not_compute : bool, optional
|
|
350
|
+
``True`` (the default) keeps GLPI from stamping the ticket again
|
|
351
|
+
in the same write. ``False`` lets an account allowed to take the
|
|
352
|
+
ticket into account undo the clear at once.
|
|
353
|
+
disable_notifications : bool, optional
|
|
354
|
+
``True`` (the default) suppresses the "ticket updated"
|
|
355
|
+
notification.
|
|
356
|
+
|
|
357
|
+
Raises
|
|
358
|
+
------
|
|
359
|
+
RuntimeError
|
|
360
|
+
When no legacy v1 session is configured on the client.
|
|
361
|
+
GlpiStatusError
|
|
362
|
+
When the legacy API returns a non-success status.
|
|
363
|
+
GlpiProtocolError
|
|
364
|
+
When the legacy API answers that the update was refused.
|
|
365
|
+
"""
|
|
366
|
+
|
|
367
|
+
self.change_ticket_take_into_account(
|
|
368
|
+
ticket_id,
|
|
369
|
+
take_into_account_date=None,
|
|
370
|
+
take_into_account_duration=0,
|
|
371
|
+
do_not_compute=do_not_compute,
|
|
372
|
+
disable_notifications=disable_notifications,
|
|
373
|
+
)
|
|
374
|
+
|
|
243
375
|
|
|
244
376
|
__all__ = ["TicketMixin"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: glpi-python-client
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.8
|
|
4
4
|
Summary: A typed Python client for GLPI ITSM APIs.
|
|
5
5
|
Project-URL: Homepage, https://github.com/baraline/glpi_python_client
|
|
6
6
|
Project-URL: Documentation, https://glpi-python-client.readthedocs.io/en/latest/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
glpi_python_client/__init__.py,sha256=
|
|
1
|
+
glpi_python_client/__init__.py,sha256=gW8x9fJRzEx95wmAJYbe7ST7Ix9sOIxe46mTMCzXjSg,5810
|
|
2
2
|
glpi_python_client/_errors.py,sha256=Bc9UvlxulbdcGvzZIKXnJCTL78sW78R6EFg50P-1dpY,7151
|
|
3
3
|
glpi_python_client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
glpi_python_client/rsql.py,sha256=3u3lH3_-F1bvHbVzxALXTDPoHyoMATP1f4QPTar_sEU,8974
|
|
@@ -20,7 +20,7 @@ glpi_python_client/_async/clients/api/assets/__init__.py,sha256=WFWG5zcRf0kFtz35
|
|
|
20
20
|
glpi_python_client/_async/clients/api/assets/_computer.py,sha256=U-dDeYmY3MaS0BTqJAQThKtKTbvDS7BvshbXheD64rM,13634
|
|
21
21
|
glpi_python_client/_async/clients/api/assistance/__init__.py,sha256=nL77QpQ4YzfdSWhkpUfcp5SwYlfjtONL37RgjU_OTuM,302
|
|
22
22
|
glpi_python_client/_async/clients/api/assistance/_team.py,sha256=QEwFTXE8W_MURi_zgfDTLoqYP__NF1SwBd_7dLJZg5U,3824
|
|
23
|
-
glpi_python_client/_async/clients/api/assistance/_ticket.py,sha256=
|
|
23
|
+
glpi_python_client/_async/clients/api/assistance/_ticket.py,sha256=F0mC0k2liCJi9dKI8uBBle1_0a9erKh5BgqAc4USI1A,13389
|
|
24
24
|
glpi_python_client/_async/clients/api/assistance/timeline/__init__.py,sha256=AqB_UpcRMHjfvZyLBjkwfsnEBwz77xBbGJzXzWmS7os,619
|
|
25
25
|
glpi_python_client/_async/clients/api/assistance/timeline/_document.py,sha256=BYCScaSyfrPzAh-znObYh1yEeL4dwYLYV8F0hKn6YcE,14803
|
|
26
26
|
glpi_python_client/_async/clients/api/assistance/timeline/_followup.py,sha256=jgE_kpJxMa3v1Tt4Jm2PahiRNX7v3vKh6xjbX27sp7w,6221
|
|
@@ -67,7 +67,7 @@ glpi_python_client/_sync/clients/api/assets/__init__.py,sha256=_4-S2nkXQNuFXzZzX
|
|
|
67
67
|
glpi_python_client/_sync/clients/api/assets/_computer.py,sha256=jILfoo7L2FJwL7Q_uFXkpfDBCuPczCAJ_TbAoyiGrj0,13490
|
|
68
68
|
glpi_python_client/_sync/clients/api/assistance/__init__.py,sha256=dAXVQPgCmPhCLESRC8nkVvCKLwp655wu9nsyqmvzLDk,300
|
|
69
69
|
glpi_python_client/_sync/clients/api/assistance/_team.py,sha256=Nk0FXUHyZZOkg62Os4FBee3Jv4YzMJoOqsvsWM0yqI0,3785
|
|
70
|
-
glpi_python_client/_sync/clients/api/assistance/_ticket.py,sha256=
|
|
70
|
+
glpi_python_client/_sync/clients/api/assistance/_ticket.py,sha256=mWJsHcIk806iudiXJuPM3CW8nn1r8tVRs3dMvtpfVhs,13280
|
|
71
71
|
glpi_python_client/_sync/clients/api/assistance/timeline/__init__.py,sha256=d_YAwgv3r1sNrRVlPC5r1yEhbUZQKzLtuNzHD9eBF8Y,615
|
|
72
72
|
glpi_python_client/_sync/clients/api/assistance/timeline/_document.py,sha256=0T7wEyVNoECI8c0LUZ1WQtXgvpRBKyl-GTsB4jdJ2xA,14709
|
|
73
73
|
glpi_python_client/_sync/clients/api/assistance/timeline/_followup.py,sha256=trQJJThA8jk2jVK-jTW8uPZyYEvR5Zi18mqGT6436VM,6158
|
|
@@ -140,7 +140,7 @@ glpi_python_client/models/custom_schema/_ticket_context.py,sha256=jnlfgho-aDbmA9
|
|
|
140
140
|
glpi_python_client/testing/__init__.py,sha256=iLtUyJjyv3fEhy3PN25NxNTbtqDl3SoHLbNium0Z80U,568
|
|
141
141
|
glpi_python_client/testing/fixtures.py,sha256=HKt6MXHgcmLn4L98pSwp-oGlc9C--_vrABNe5G_iBeg,1286
|
|
142
142
|
glpi_python_client/testing/utils.py,sha256=JyO3w2d-0kYdtC1hEZ2Tu_YjnCz8nUQ_Ck05-1EhsX4,4404
|
|
143
|
-
glpi_python_client-0.6.
|
|
144
|
-
glpi_python_client-0.6.
|
|
145
|
-
glpi_python_client-0.6.
|
|
146
|
-
glpi_python_client-0.6.
|
|
143
|
+
glpi_python_client-0.6.8.dist-info/METADATA,sha256=NO8Su8O8dS0rA3fzg_Heai9rxsNdsPElUHsmmsW8UbY,8234
|
|
144
|
+
glpi_python_client-0.6.8.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
145
|
+
glpi_python_client-0.6.8.dist-info/licenses/LICENSE,sha256=nL8re-TIKkxCoL7OkSBja6EB4NsQR1HoOJgxv_MEhtc,1088
|
|
146
|
+
glpi_python_client-0.6.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|