glpi-python-client 0.1.0__tar.gz
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-0.1.0/.gitignore +30 -0
- glpi_python_client-0.1.0/.readthedocs.yaml +17 -0
- glpi_python_client-0.1.0/CONTRIBUTING.md +51 -0
- glpi_python_client-0.1.0/LICENSE +21 -0
- glpi_python_client-0.1.0/PKG-INFO +144 -0
- glpi_python_client-0.1.0/README.md +92 -0
- glpi_python_client-0.1.0/docs/_static/.gitkeep +0 -0
- glpi_python_client-0.1.0/docs/api_reference.rst +76 -0
- glpi_python_client-0.1.0/docs/conf.py +66 -0
- glpi_python_client-0.1.0/docs/development.md +90 -0
- glpi_python_client-0.1.0/docs/development_rtd.rst +61 -0
- glpi_python_client-0.1.0/docs/index.rst +33 -0
- glpi_python_client-0.1.0/docs/installation.rst +54 -0
- glpi_python_client-0.1.0/docs/publishing.md +75 -0
- glpi_python_client-0.1.0/docs/publishing_rtd.rst +113 -0
- glpi_python_client-0.1.0/docs/usage.md +254 -0
- glpi_python_client-0.1.0/docs/user_guide.rst +438 -0
- glpi_python_client-0.1.0/glpi_python_client/__init__.py +36 -0
- glpi_python_client-0.1.0/glpi_python_client/auth/__init__.py +11 -0
- glpi_python_client-0.1.0/glpi_python_client/auth/auth.py +310 -0
- glpi_python_client-0.1.0/glpi_python_client/auth/tests/test_auth.py +189 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/__init__.py +18 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/api_v1_session.py +460 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/api_v2_client.py +317 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/async_api_v2_client.py +236 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/tests/__init__.py +5 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/tests/test_api_v1_session.py +85 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/tests/test_api_v2_client.py +349 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/tests/test_async_api_v2_client.py +257 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/__init__.py +8 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/async_/__init__.py +12 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/async_/api.py +29 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/async_/directory.py +88 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/async_/documents.py +144 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/async_/team.py +125 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/async_/tests/__init__.py +5 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/async_/tests/test_directory.py +43 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/async_/tests/test_documents.py +41 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/async_/tests/test_team.py +44 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/async_/tests/test_tickets.py +174 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/async_/tests/test_timeline.py +126 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/async_/tickets.py +312 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/async_/timeline.py +312 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/async_/transport.py +251 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/common/__init__.py +6 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/common/client_config.py +219 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/common/constants.py +45 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/common/errors.py +23 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/common/filters.py +30 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/common/payloads.py +57 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/common/request_http.py +195 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/common/response_payloads.py +76 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/common/ticket_search.py +113 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/sync/__init__.py +12 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/sync/api.py +29 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/sync/directory.py +90 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/sync/documents.py +144 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/sync/team.py +125 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/sync/tests/__init__.py +5 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/sync/tests/test_directory.py +57 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/sync/tests/test_documents.py +99 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/sync/tests/test_team.py +64 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/sync/tests/test_tickets.py +430 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/sync/tests/test_timeline.py +77 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/sync/tests/test_transport.py +89 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/sync/tickets.py +312 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/sync/timeline.py +308 -0
- glpi_python_client-0.1.0/glpi_python_client/clients/v2/sync/transport.py +246 -0
- glpi_python_client-0.1.0/glpi_python_client/content/__init__.py +11 -0
- glpi_python_client-0.1.0/glpi_python_client/content/conversion.py +58 -0
- glpi_python_client-0.1.0/glpi_python_client/content/records/__init__.py +84 -0
- glpi_python_client-0.1.0/glpi_python_client/content/records/core/__init__.py +6 -0
- glpi_python_client-0.1.0/glpi_python_client/content/records/core/document_links.py +100 -0
- glpi_python_client-0.1.0/glpi_python_client/content/records/core/normalization.py +53 -0
- glpi_python_client-0.1.0/glpi_python_client/content/records/core/references.py +98 -0
- glpi_python_client-0.1.0/glpi_python_client/content/records/core/scalars.py +83 -0
- glpi_python_client-0.1.0/glpi_python_client/content/records/parsers/__init__.py +6 -0
- glpi_python_client-0.1.0/glpi_python_client/content/records/parsers/directory.py +62 -0
- glpi_python_client-0.1.0/glpi_python_client/content/records/parsers/documents.py +49 -0
- glpi_python_client-0.1.0/glpi_python_client/content/records/parsers/team.py +58 -0
- glpi_python_client-0.1.0/glpi_python_client/content/records/parsers/tests/__init__.py +5 -0
- glpi_python_client-0.1.0/glpi_python_client/content/records/parsers/tests/test_tickets.py +35 -0
- glpi_python_client-0.1.0/glpi_python_client/content/records/parsers/tests/test_timeline.py +20 -0
- glpi_python_client-0.1.0/glpi_python_client/content/records/parsers/tickets.py +96 -0
- glpi_python_client-0.1.0/glpi_python_client/content/records/parsers/timeline.py +119 -0
- glpi_python_client-0.1.0/glpi_python_client/content/tests/__init__.py +5 -0
- glpi_python_client-0.1.0/glpi_python_client/content/tests/test_conversion.py +13 -0
- glpi_python_client-0.1.0/glpi_python_client/models/__init__.py +30 -0
- glpi_python_client-0.1.0/glpi_python_client/models/_base.py +22 -0
- glpi_python_client-0.1.0/glpi_python_client/models/_payload.py +79 -0
- glpi_python_client-0.1.0/glpi_python_client/models/_shared.py +37 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/__init__.py +27 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/_document.py +59 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/_followup.py +77 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/_location.py +53 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/_solution.py +57 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/_task.py +41 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/_team_member.py +33 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/_ticket.py +303 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/_user.py +92 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/tests/__init__.py +5 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/tests/test__document.py +12 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/tests/test__followup.py +31 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/tests/test__location.py +12 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/tests/test__solution.py +11 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/tests/test__ticket.py +59 -0
- glpi_python_client-0.1.0/glpi_python_client/models/glpi/tests/test__user.py +29 -0
- glpi_python_client-0.1.0/glpi_python_client/py.typed +0 -0
- glpi_python_client-0.1.0/glpi_python_client/testing/__init__.py +27 -0
- glpi_python_client-0.1.0/glpi_python_client/testing/fixtures.py +52 -0
- glpi_python_client-0.1.0/glpi_python_client/testing/utils.py +149 -0
- glpi_python_client-0.1.0/pyproject.toml +127 -0
- glpi_python_client-0.1.0/skills/README.md +25 -0
- glpi_python_client-0.1.0/skills/glpi-client-setup/SKILL.md +96 -0
- glpi_python_client-0.1.0/skills/glpi-document-workflow/SKILL.md +90 -0
- glpi_python_client-0.1.0/skills/glpi-team-members/SKILL.md +63 -0
- glpi_python_client-0.1.0/skills/glpi-ticket-timeline/SKILL.md +88 -0
- glpi_python_client-0.1.0/skills/glpi-ticket-workflow/SKILL.md +92 -0
- glpi_python_client-0.1.0/skills/glpi-user-location-provisioning/SKILL.md +75 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Bytecode and caches
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
.pytest_cache/
|
|
5
|
+
.mypy_cache/
|
|
6
|
+
.ruff_cache/
|
|
7
|
+
|
|
8
|
+
# Packaging
|
|
9
|
+
build/
|
|
10
|
+
dist/
|
|
11
|
+
*.egg-info/
|
|
12
|
+
docs/_build/
|
|
13
|
+
|
|
14
|
+
# Virtual environments
|
|
15
|
+
.venv/
|
|
16
|
+
venv/
|
|
17
|
+
|
|
18
|
+
# Local configuration
|
|
19
|
+
.env
|
|
20
|
+
.env.*
|
|
21
|
+
|
|
22
|
+
*.pyc
|
|
23
|
+
dist/
|
|
24
|
+
.venv/
|
|
25
|
+
|
|
26
|
+
secrets/
|
|
27
|
+
secrets/*
|
|
28
|
+
|
|
29
|
+
integration_tests/
|
|
30
|
+
integration_tests/*
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thank you for improving `glpi-python-client`.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
python -m venv .venv
|
|
9
|
+
.venv\Scripts\activate
|
|
10
|
+
python -m pip install -e .[dev]
|
|
11
|
+
python -m pytest
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quality Checks
|
|
15
|
+
|
|
16
|
+
Run the focused checks before opening a pull request:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
python -m pytest
|
|
20
|
+
python -m ruff check .
|
|
21
|
+
python -m mypy glpi_python_client
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Documentation build
|
|
25
|
+
|
|
26
|
+
To build the documentation locally:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
python -m sphinx -W --keep-going -b html docs docs/_build/html pa
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## GitHub Actions
|
|
33
|
+
|
|
34
|
+
- `.github/workflows/ci.yml` runs tests for Python 3.10 through 3.13 on pull
|
|
35
|
+
requests and pushes to `main`.
|
|
36
|
+
- The same workflow runs `ruff`, `mypy`, and a warning-free Sphinx build on
|
|
37
|
+
Python 3.12.
|
|
38
|
+
- When `READTHEDOCS_TOKEN` and `READTHEDOCS_PROJECT` are configured as GitHub
|
|
39
|
+
secrets, pushes to `main` also trigger the Read the Docs `latest` build.
|
|
40
|
+
- `.github/workflows/release.yml` repeats the checks for published releases,
|
|
41
|
+
builds the distribution artifacts, and triggers the configured release docs
|
|
42
|
+
build on Read the Docs.
|
|
43
|
+
|
|
44
|
+
## Design Guidelines
|
|
45
|
+
|
|
46
|
+
- Keep API calls behind `GlpiClient` methods.
|
|
47
|
+
- Prefer field-validated Pydantic models for request and response payloads.
|
|
48
|
+
- Avoid organization-specific category, entity, or profile defaults in the
|
|
49
|
+
library core.
|
|
50
|
+
- Add tests for payload serialization and response normalization when adding
|
|
51
|
+
endpoints.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 glpi-python-client contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: glpi-python-client
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A typed Python client for GLPI ITSM APIs.
|
|
5
|
+
Project-URL: Homepage, https://github.com/baraline/glpi_python_client
|
|
6
|
+
Project-URL: Documentation, https://glpi-python-client.readthedocs.io/en/latest/
|
|
7
|
+
Project-URL: Issues, https://github.com/baraline/glpi_python_client/issues
|
|
8
|
+
Project-URL: Source, https://github.com/baraline/glpi_python_client
|
|
9
|
+
Author: glpi-python-client contributors
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: api,client,glpi,itsm
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Requires-Dist: beautifulsoup4>=4.12
|
|
27
|
+
Requires-Dist: lxml>=4.9
|
|
28
|
+
Requires-Dist: markdown>=3.6
|
|
29
|
+
Requires-Dist: markdownify>=0.13
|
|
30
|
+
Requires-Dist: pydantic>=2.8
|
|
31
|
+
Requires-Dist: requests>=2.31
|
|
32
|
+
Requires-Dist: tenacity>=8.2
|
|
33
|
+
Requires-Dist: urllib3>=2.0
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: build>=1.2; extra == 'dev'
|
|
36
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
37
|
+
Requires-Dist: numpydoc>=1.8; extra == 'dev'
|
|
38
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
39
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
40
|
+
Requires-Dist: sphinx-rtd-theme>=2.0; extra == 'dev'
|
|
41
|
+
Requires-Dist: sphinx<8.2,>=7.2; extra == 'dev'
|
|
42
|
+
Requires-Dist: tomli>=2.0; (python_version < '3.11') and extra == 'dev'
|
|
43
|
+
Requires-Dist: twine>=5.1; extra == 'dev'
|
|
44
|
+
Requires-Dist: types-requests>=2.32; extra == 'dev'
|
|
45
|
+
Requires-Dist: vulture>=2.11; extra == 'dev'
|
|
46
|
+
Provides-Extra: docs
|
|
47
|
+
Requires-Dist: numpydoc>=1.8; extra == 'docs'
|
|
48
|
+
Requires-Dist: sphinx-rtd-theme>=2.0; extra == 'docs'
|
|
49
|
+
Requires-Dist: sphinx<8.2,>=7.2; extra == 'docs'
|
|
50
|
+
Requires-Dist: tomli>=2.0; (python_version < '3.11') and extra == 'docs'
|
|
51
|
+
Description-Content-Type: text/markdown
|
|
52
|
+
|
|
53
|
+
# glpi-python-client
|
|
54
|
+
|
|
55
|
+
[](https://github.com/baraline/glpi_python_client/actions/workflows/ci.yml)
|
|
56
|
+
[](LICENSE)
|
|
57
|
+
[](https://github.com/baraline/glpi_python_client)
|
|
58
|
+
[](https://glpi-python-client.readthedocs.io/en/latest/)
|
|
59
|
+
|
|
60
|
+
`glpi-python-client` is a typed Python client for GLPI ITSM APIs.
|
|
61
|
+
|
|
62
|
+
The goal is to let GLPI integrations work with domain objects instead of raw
|
|
63
|
+
JSON payloads. The package exposes Pydantic models for tickets, users,
|
|
64
|
+
followups, documents, locations, and related records, while converting GLPI
|
|
65
|
+
HTML content into Markdown for Python-side workflows and rendering Markdown
|
|
66
|
+
back to HTML for outgoing payloads.
|
|
67
|
+
|
|
68
|
+
It currently focuses on ticket-centric workflows and exposes matching sync and
|
|
69
|
+
async high-level clients.
|
|
70
|
+
|
|
71
|
+
## Installation
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install glpi-python-client
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
For local development:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
python -m pip install -e .[dev]
|
|
81
|
+
python -m pytest
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Quick Start
|
|
85
|
+
|
|
86
|
+
Create a client with your GLPI API URL and at least one complete auth pair:
|
|
87
|
+
|
|
88
|
+
- `client_id` and `client_secret`
|
|
89
|
+
- `username` and `password`
|
|
90
|
+
- both pairs together
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from glpi_python_client import GlpiClient, GlpiTicket
|
|
94
|
+
|
|
95
|
+
with GlpiClient(
|
|
96
|
+
glpi_api_url="https://glpi.example.com/api.php",
|
|
97
|
+
client_id="oauth-client-id",
|
|
98
|
+
client_secret="oauth-client-secret",
|
|
99
|
+
username="api-user",
|
|
100
|
+
password="api-password",
|
|
101
|
+
) as glpi:
|
|
102
|
+
ticket_id = glpi.create_ticket(
|
|
103
|
+
GlpiTicket(
|
|
104
|
+
name="Printer issue",
|
|
105
|
+
content="The printer is not reachable from the office network.",
|
|
106
|
+
urgency=3,
|
|
107
|
+
impact=3,
|
|
108
|
+
)
|
|
109
|
+
)
|
|
110
|
+
ticket = glpi.get_ticket_record(ticket_id)
|
|
111
|
+
|
|
112
|
+
print(ticket.id)
|
|
113
|
+
print(ticket.content)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Async code uses the same model layer and nearly the same API surface:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from glpi_python_client import AsyncGlpiClient
|
|
120
|
+
|
|
121
|
+
async with AsyncGlpiClient(
|
|
122
|
+
glpi_api_url="https://glpi.example.com/api.php",
|
|
123
|
+
client_id="oauth-client-id",
|
|
124
|
+
client_secret="oauth-client-secret",
|
|
125
|
+
) as glpi:
|
|
126
|
+
tickets = await glpi.search_ticket_records(query='status.id=in=(1,2)')
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
If your application already provides `GLPI_` environment variables,
|
|
130
|
+
`GlpiClient.from_env()` and `AsyncGlpiClient.from_env()` are also available.
|
|
131
|
+
|
|
132
|
+
## Documentation
|
|
133
|
+
|
|
134
|
+
- [Hosted documentation](https://glpi-python-client.readthedocs.io/en/latest/)
|
|
135
|
+
- [API reference](https://glpi-python-client.readthedocs.io/en/latest/api_reference.html)
|
|
136
|
+
- [Installation guide](https://glpi-python-client.readthedocs.io/en/latest/installation.html)
|
|
137
|
+
- [Development guide](https://glpi-python-client.readthedocs.io/en/latest/development_rtd.html)
|
|
138
|
+
|
|
139
|
+
To build the Sphinx documentation locally:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
python -m pip install -e .[docs]
|
|
143
|
+
python -m sphinx -b html docs docs/_build/html
|
|
144
|
+
```
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# glpi-python-client
|
|
2
|
+
|
|
3
|
+
[](https://github.com/baraline/glpi_python_client/actions/workflows/ci.yml)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://github.com/baraline/glpi_python_client)
|
|
6
|
+
[](https://glpi-python-client.readthedocs.io/en/latest/)
|
|
7
|
+
|
|
8
|
+
`glpi-python-client` is a typed Python client for GLPI ITSM APIs.
|
|
9
|
+
|
|
10
|
+
The goal is to let GLPI integrations work with domain objects instead of raw
|
|
11
|
+
JSON payloads. The package exposes Pydantic models for tickets, users,
|
|
12
|
+
followups, documents, locations, and related records, while converting GLPI
|
|
13
|
+
HTML content into Markdown for Python-side workflows and rendering Markdown
|
|
14
|
+
back to HTML for outgoing payloads.
|
|
15
|
+
|
|
16
|
+
It currently focuses on ticket-centric workflows and exposes matching sync and
|
|
17
|
+
async high-level clients.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install glpi-python-client
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
For local development:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
python -m pip install -e .[dev]
|
|
29
|
+
python -m pytest
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
Create a client with your GLPI API URL and at least one complete auth pair:
|
|
35
|
+
|
|
36
|
+
- `client_id` and `client_secret`
|
|
37
|
+
- `username` and `password`
|
|
38
|
+
- both pairs together
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from glpi_python_client import GlpiClient, GlpiTicket
|
|
42
|
+
|
|
43
|
+
with GlpiClient(
|
|
44
|
+
glpi_api_url="https://glpi.example.com/api.php",
|
|
45
|
+
client_id="oauth-client-id",
|
|
46
|
+
client_secret="oauth-client-secret",
|
|
47
|
+
username="api-user",
|
|
48
|
+
password="api-password",
|
|
49
|
+
) as glpi:
|
|
50
|
+
ticket_id = glpi.create_ticket(
|
|
51
|
+
GlpiTicket(
|
|
52
|
+
name="Printer issue",
|
|
53
|
+
content="The printer is not reachable from the office network.",
|
|
54
|
+
urgency=3,
|
|
55
|
+
impact=3,
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
ticket = glpi.get_ticket_record(ticket_id)
|
|
59
|
+
|
|
60
|
+
print(ticket.id)
|
|
61
|
+
print(ticket.content)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Async code uses the same model layer and nearly the same API surface:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from glpi_python_client import AsyncGlpiClient
|
|
68
|
+
|
|
69
|
+
async with AsyncGlpiClient(
|
|
70
|
+
glpi_api_url="https://glpi.example.com/api.php",
|
|
71
|
+
client_id="oauth-client-id",
|
|
72
|
+
client_secret="oauth-client-secret",
|
|
73
|
+
) as glpi:
|
|
74
|
+
tickets = await glpi.search_ticket_records(query='status.id=in=(1,2)')
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
If your application already provides `GLPI_` environment variables,
|
|
78
|
+
`GlpiClient.from_env()` and `AsyncGlpiClient.from_env()` are also available.
|
|
79
|
+
|
|
80
|
+
## Documentation
|
|
81
|
+
|
|
82
|
+
- [Hosted documentation](https://glpi-python-client.readthedocs.io/en/latest/)
|
|
83
|
+
- [API reference](https://glpi-python-client.readthedocs.io/en/latest/api_reference.html)
|
|
84
|
+
- [Installation guide](https://glpi-python-client.readthedocs.io/en/latest/installation.html)
|
|
85
|
+
- [Development guide](https://glpi-python-client.readthedocs.io/en/latest/development_rtd.html)
|
|
86
|
+
|
|
87
|
+
To build the Sphinx documentation locally:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
python -m pip install -e .[docs]
|
|
91
|
+
python -m sphinx -b html docs docs/_build/html
|
|
92
|
+
```
|
|
File without changes
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
API Reference
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
This reference documents the public package surface exported by ``glpi_python_client``.
|
|
5
|
+
Internal implementation modules and underscore-prefixed helpers are
|
|
6
|
+
intentionally omitted.
|
|
7
|
+
|
|
8
|
+
.. currentmodule:: glpi_python_client
|
|
9
|
+
|
|
10
|
+
Client
|
|
11
|
+
------
|
|
12
|
+
|
|
13
|
+
.. autoclass:: GlpiClient
|
|
14
|
+
:members:
|
|
15
|
+
:inherited-members:
|
|
16
|
+
:show-inheritance:
|
|
17
|
+
|
|
18
|
+
.. autoclass:: AsyncGlpiClient
|
|
19
|
+
:members:
|
|
20
|
+
:inherited-members:
|
|
21
|
+
:show-inheritance:
|
|
22
|
+
|
|
23
|
+
Legacy v1 Session
|
|
24
|
+
-----------------
|
|
25
|
+
|
|
26
|
+
.. autoclass:: GLPIV1Session
|
|
27
|
+
:members:
|
|
28
|
+
:show-inheritance:
|
|
29
|
+
|
|
30
|
+
Models
|
|
31
|
+
------
|
|
32
|
+
|
|
33
|
+
.. autoclass:: GlpiUser
|
|
34
|
+
:members:
|
|
35
|
+
:undoc-members:
|
|
36
|
+
:show-inheritance:
|
|
37
|
+
|
|
38
|
+
.. autoclass:: GlpiLocation
|
|
39
|
+
:members:
|
|
40
|
+
:undoc-members:
|
|
41
|
+
:show-inheritance:
|
|
42
|
+
|
|
43
|
+
.. autoclass:: GlpiTicket
|
|
44
|
+
:members:
|
|
45
|
+
:undoc-members:
|
|
46
|
+
:show-inheritance:
|
|
47
|
+
|
|
48
|
+
.. autoclass:: GlpiFollowup
|
|
49
|
+
:members:
|
|
50
|
+
:undoc-members:
|
|
51
|
+
:show-inheritance:
|
|
52
|
+
|
|
53
|
+
.. autoclass:: GlpiTask
|
|
54
|
+
:members:
|
|
55
|
+
:undoc-members:
|
|
56
|
+
:show-inheritance:
|
|
57
|
+
|
|
58
|
+
.. autoclass:: GlpiSolution
|
|
59
|
+
:members:
|
|
60
|
+
:undoc-members:
|
|
61
|
+
:show-inheritance:
|
|
62
|
+
|
|
63
|
+
.. autoclass:: GlpiDocument
|
|
64
|
+
:members:
|
|
65
|
+
:undoc-members:
|
|
66
|
+
:show-inheritance:
|
|
67
|
+
|
|
68
|
+
.. autoclass:: GlpiTeamMember
|
|
69
|
+
:members:
|
|
70
|
+
:undoc-members:
|
|
71
|
+
:show-inheritance:
|
|
72
|
+
|
|
73
|
+
Package Metadata
|
|
74
|
+
----------------
|
|
75
|
+
|
|
76
|
+
.. autodata:: __version__
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""Sphinx configuration for the glpi-python-client documentation."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from datetime import date
|
|
6
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
from tomllib import loads as toml_loads
|
|
11
|
+
except ModuleNotFoundError:
|
|
12
|
+
from tomli import loads as toml_loads
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _read_project_version() -> str:
|
|
16
|
+
pyproject_path = Path(__file__).resolve().parents[1] / "pyproject.toml"
|
|
17
|
+
pyproject_data = toml_loads(pyproject_path.read_text(encoding="utf-8"))
|
|
18
|
+
return str(pyproject_data["project"]["version"])
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
project = "glpi-python-client"
|
|
22
|
+
author = "glpi-python-client contributors"
|
|
23
|
+
copyright = f"{date.today().year}, {author}"
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
release = version("glpi-python-client")
|
|
27
|
+
except PackageNotFoundError:
|
|
28
|
+
release = _read_project_version()
|
|
29
|
+
|
|
30
|
+
version = release
|
|
31
|
+
|
|
32
|
+
extensions = [
|
|
33
|
+
"numpydoc",
|
|
34
|
+
"sphinx.ext.autodoc",
|
|
35
|
+
"sphinx.ext.autosummary",
|
|
36
|
+
"sphinx.ext.intersphinx",
|
|
37
|
+
"sphinx.ext.viewcode",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
templates_path = ["_templates"]
|
|
41
|
+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
|
42
|
+
|
|
43
|
+
html_theme = "sphinx_rtd_theme"
|
|
44
|
+
html_static_path = ["_static"]
|
|
45
|
+
html_title = "glpi-python-client documentation"
|
|
46
|
+
|
|
47
|
+
add_module_names = False
|
|
48
|
+
autoclass_content = "both"
|
|
49
|
+
autodoc_class_signature = "mixed"
|
|
50
|
+
autodoc_default_options = {
|
|
51
|
+
"members": True,
|
|
52
|
+
"undoc-members": True,
|
|
53
|
+
"show-inheritance": True,
|
|
54
|
+
"special-members": "__enter__, __exit__",
|
|
55
|
+
}
|
|
56
|
+
autodoc_typehints = "description"
|
|
57
|
+
autosummary_generate = True
|
|
58
|
+
|
|
59
|
+
numpydoc_class_members_toctree = False
|
|
60
|
+
numpydoc_show_class_members = True
|
|
61
|
+
numpydoc_xref_param_type = True
|
|
62
|
+
|
|
63
|
+
intersphinx_mapping = {
|
|
64
|
+
"python": ("https://docs.python.org/3", None),
|
|
65
|
+
"requests": ("https://requests.readthedocs.io/en/latest/", None),
|
|
66
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Development Guide
|
|
2
|
+
|
|
3
|
+
## Local Setup
|
|
4
|
+
|
|
5
|
+
Create a virtual environment and install the package with development dependencies:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
python -m venv .venv
|
|
9
|
+
.venv\Scripts\activate
|
|
10
|
+
python -m pip install --upgrade pip
|
|
11
|
+
python -m pip install -e .[dev]
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Checks
|
|
15
|
+
|
|
16
|
+
Run these before publishing or opening a pull request:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
python -m pytest
|
|
20
|
+
python -m ruff check .
|
|
21
|
+
python -m mypy glpi_python_client
|
|
22
|
+
python -m sphinx -b html docs docs/_build/html
|
|
23
|
+
python -m build
|
|
24
|
+
python -m vulture glpi_python_client --min-confidence 80
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
If your global Python environment has broken pytest plugins, run the suite with
|
|
28
|
+
plugin autoload disabled:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
$env:PYTEST_DISABLE_PLUGIN_AUTOLOAD = "1"
|
|
32
|
+
python -m pytest
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Package Layout
|
|
36
|
+
|
|
37
|
+
- `glpi_python_client.__init__` exposes the public import surface.
|
|
38
|
+
- `glpi_python_client.clients.api_v2_client.GlpiClient` owns synchronous API
|
|
39
|
+
configuration, authentication, context-manager cleanup, and the small
|
|
40
|
+
user/location/document provisioning surface.
|
|
41
|
+
- `glpi_python_client.clients.async_api_v2_client.AsyncGlpiClient` owns the
|
|
42
|
+
matching awaitable client surface and keeps blocking requests behind
|
|
43
|
+
`asyncio.to_thread()` boundaries.
|
|
44
|
+
- `glpi_python_client.clients.v2` contains the internal v2 implementation
|
|
45
|
+
packages.
|
|
46
|
+
- `glpi_python_client.clients.v2.common` holds reusable setup, endpoint,
|
|
47
|
+
request, pagination, payload, filter, and error helpers shared by both
|
|
48
|
+
execution models.
|
|
49
|
+
- `glpi_python_client.clients.v2.sync` contains the synchronous endpoint mixins:
|
|
50
|
+
`transport`, `tickets`, `timeline`, `documents`, `team`, and `directory`.
|
|
51
|
+
`sync.api` assembles those mixins.
|
|
52
|
+
- `glpi_python_client.clients.v2.async_` contains the matching asynchronous
|
|
53
|
+
endpoint mixins and keeps `asyncio.to_thread()` at the blocking request and
|
|
54
|
+
v1-session boundaries. `async_.api` assembles those mixins.
|
|
55
|
+
- `glpi_python_client.clients._shared` is a compatibility module that re-exports
|
|
56
|
+
the scoped v2 helper modules for older internal imports.
|
|
57
|
+
- `glpi_python_client.clients.api_v1_session` contains the legacy v1 session
|
|
58
|
+
used for document operations.
|
|
59
|
+
- `glpi_python_client.models` contains typed request and response models.
|
|
60
|
+
- `glpi_python_client.content.records` is a compatibility package for raw GLPI
|
|
61
|
+
payload conversion.
|
|
62
|
+
- `glpi_python_client.content.records.core` contains shared normalization,
|
|
63
|
+
scalar coercion, nested-reference parsing, and timeline document-link
|
|
64
|
+
helpers.
|
|
65
|
+
- `glpi_python_client.content.records.parsers` contains model-specific parsers
|
|
66
|
+
for tickets, timeline items, documents, team members, users, and locations.
|
|
67
|
+
- `docs` contains the Read the Docs/Sphinx documentation source.
|
|
68
|
+
- `skills` contains contributor-facing Agent Skills for repository workflows.
|
|
69
|
+
The source distribution includes them for source consumers and contributors,
|
|
70
|
+
but the wheel still installs only the `glpi_python_client` runtime package.
|
|
71
|
+
|
|
72
|
+
## Adding Endpoints
|
|
73
|
+
|
|
74
|
+
1. Add or extend a model in `glpi_python_client.models`.
|
|
75
|
+
2. Add response parsing in the matching
|
|
76
|
+
`glpi_python_client.content.records.parsers` module when the endpoint returns
|
|
77
|
+
structured data, and put shared parsing helpers in
|
|
78
|
+
`glpi_python_client.content.records.core` only when multiple parsers need
|
|
79
|
+
them.
|
|
80
|
+
3. Add the client method in the matching
|
|
81
|
+
`glpi_python_client.clients.v2.sync` module and the matching
|
|
82
|
+
`glpi_python_client.clients.v2.async_` module when applicable.
|
|
83
|
+
4. Put reusable endpoint names, payload builders, response handling, or
|
|
84
|
+
pagination logic in the focused `glpi_python_client.clients.v2.common`
|
|
85
|
+
helper module named for that responsibility.
|
|
86
|
+
5. Add tests for payload serialization, response parsing, and client behavior.
|
|
87
|
+
6. Document the new workflow in `docs/usage.md` or the README.
|
|
88
|
+
|
|
89
|
+
Keep organization-specific defaults outside the package core. Applications can
|
|
90
|
+
map their own entities, profiles, and categories before calling the client.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Development
|
|
2
|
+
===========
|
|
3
|
+
|
|
4
|
+
Local Setup
|
|
5
|
+
-----------
|
|
6
|
+
|
|
7
|
+
Create a virtual environment and install the development dependencies:
|
|
8
|
+
|
|
9
|
+
.. code-block:: console
|
|
10
|
+
|
|
11
|
+
python -m venv .venv
|
|
12
|
+
.venv\Scripts\activate
|
|
13
|
+
python -m pip install --upgrade pip
|
|
14
|
+
python -m pip install -e .[dev]
|
|
15
|
+
|
|
16
|
+
Quality Checks
|
|
17
|
+
--------------
|
|
18
|
+
|
|
19
|
+
Run the focused checks before opening a pull request:
|
|
20
|
+
|
|
21
|
+
.. code-block:: console
|
|
22
|
+
|
|
23
|
+
python -m pytest
|
|
24
|
+
python -m ruff check .
|
|
25
|
+
python -m mypy glpi_python_client
|
|
26
|
+
python -m sphinx -b html docs docs/_build/html
|
|
27
|
+
|
|
28
|
+
Package Layout
|
|
29
|
+
--------------
|
|
30
|
+
|
|
31
|
+
``glpi_python_client.__init__``
|
|
32
|
+
Public import surface.
|
|
33
|
+
|
|
34
|
+
``glpi_python_client._client_v2``
|
|
35
|
+
Main ``GlpiClient`` implementation, configuration, authentication, and
|
|
36
|
+
context-manager cleanup.
|
|
37
|
+
|
|
38
|
+
``glpi_python_client._api``
|
|
39
|
+
High-level GLPI endpoint helpers.
|
|
40
|
+
|
|
41
|
+
``glpi_python_client._client_v1``
|
|
42
|
+
Legacy v1 session used for document operations.
|
|
43
|
+
|
|
44
|
+
``glpi_python_client.models``
|
|
45
|
+
Typed request and response models.
|
|
46
|
+
|
|
47
|
+
``glpi_python_client._records``
|
|
48
|
+
Raw GLPI payload normalization and model conversion.
|
|
49
|
+
|
|
50
|
+
Adding Endpoints
|
|
51
|
+
----------------
|
|
52
|
+
|
|
53
|
+
#. Add or extend a model in ``glpi_python_client.models``.
|
|
54
|
+
#. Add response parsing in ``glpi_python_client._records`` when needed.
|
|
55
|
+
#. Add the client method in ``glpi_python_client._api``.
|
|
56
|
+
#. Add tests for payload serialization, response parsing, and client behavior.
|
|
57
|
+
#. Document the workflow in :doc:`user_guide` or the README.
|
|
58
|
+
|
|
59
|
+
Keep organization-specific entity, profile, and category defaults outside the
|
|
60
|
+
library core. Applications can apply their own mapping before calling the
|
|
61
|
+
client.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
glpi-python-client Documentation
|
|
2
|
+
================================
|
|
3
|
+
|
|
4
|
+
``glpi-python-client`` is a typed Python package for interacting with GLPI ITSM APIs.
|
|
5
|
+
It provides a reusable ``GlpiClient`` object, typed models, OAuth2 token
|
|
6
|
+
handling, and helpers for ticket, user, location, and document workflows.
|
|
7
|
+
|
|
8
|
+
.. toctree::
|
|
9
|
+
:maxdepth: 2
|
|
10
|
+
:caption: User Guide
|
|
11
|
+
|
|
12
|
+
installation
|
|
13
|
+
user_guide
|
|
14
|
+
|
|
15
|
+
.. toctree::
|
|
16
|
+
:maxdepth: 2
|
|
17
|
+
:caption: API Documentation
|
|
18
|
+
|
|
19
|
+
api_reference
|
|
20
|
+
|
|
21
|
+
.. toctree::
|
|
22
|
+
:maxdepth: 1
|
|
23
|
+
:caption: Project
|
|
24
|
+
|
|
25
|
+
development_rtd
|
|
26
|
+
publishing_rtd
|
|
27
|
+
|
|
28
|
+
Indices and Tables
|
|
29
|
+
==================
|
|
30
|
+
|
|
31
|
+
* :ref:`genindex`
|
|
32
|
+
* :ref:`modindex`
|
|
33
|
+
* :ref:`search`
|