lansweeper-helpdesk 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.
- lansweeper_helpdesk-0.1.0/.gitignore +40 -0
- lansweeper_helpdesk-0.1.0/CHANGELOG.md +36 -0
- lansweeper_helpdesk-0.1.0/LICENSE +21 -0
- lansweeper_helpdesk-0.1.0/PKG-INFO +260 -0
- lansweeper_helpdesk-0.1.0/README.md +220 -0
- lansweeper_helpdesk-0.1.0/pyproject.toml +85 -0
- lansweeper_helpdesk-0.1.0/src/lansweeper_helpdesk/__init__.py +27 -0
- lansweeper_helpdesk-0.1.0/src/lansweeper_helpdesk/client.py +383 -0
- lansweeper_helpdesk-0.1.0/src/lansweeper_helpdesk/exceptions.py +34 -0
- lansweeper_helpdesk-0.1.0/src/lansweeper_helpdesk/py.typed +0 -0
- lansweeper_helpdesk-0.1.0/src/lansweeper_helpdesk/types.py +32 -0
- lansweeper_helpdesk-0.1.0/tests/__init__.py +0 -0
- lansweeper_helpdesk-0.1.0/tests/conftest.py +36 -0
- lansweeper_helpdesk-0.1.0/tests/test_client.py +233 -0
- lansweeper_helpdesk-0.1.0/tests/test_types.py +23 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
*.egg
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
env/
|
|
16
|
+
|
|
17
|
+
# IDE
|
|
18
|
+
.idea/
|
|
19
|
+
.vscode/
|
|
20
|
+
*.swp
|
|
21
|
+
*.swo
|
|
22
|
+
|
|
23
|
+
# Type checking / linting caches
|
|
24
|
+
.mypy_cache/
|
|
25
|
+
.ruff_cache/
|
|
26
|
+
.pytest_cache/
|
|
27
|
+
|
|
28
|
+
# Coverage
|
|
29
|
+
htmlcov/
|
|
30
|
+
.coverage
|
|
31
|
+
.coverage.*
|
|
32
|
+
coverage.xml
|
|
33
|
+
|
|
34
|
+
# Environment / secrets
|
|
35
|
+
.env
|
|
36
|
+
config/config.json
|
|
37
|
+
|
|
38
|
+
# OS
|
|
39
|
+
.DS_Store
|
|
40
|
+
Thumbs.db
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-03-05
|
|
8
|
+
|
|
9
|
+
Initial release as a proper Python package.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Installable package via `pip install lansweeper-helpdesk`.
|
|
14
|
+
- Full type annotations on all public methods and parameters.
|
|
15
|
+
- Custom exception hierarchy: `HelpdeskError`, `APIError`, `ConfigurationError`, `TicketNotFoundError`.
|
|
16
|
+
- `TicketState` and `NoteType` enums for common API values.
|
|
17
|
+
- `py.typed` marker for PEP 561 type checker support.
|
|
18
|
+
- Comprehensive test suite using pytest and responses.
|
|
19
|
+
- CI pipeline (GitHub Actions) with testing across Python 3.10–3.13, ruff linting, and mypy type checking.
|
|
20
|
+
- PyPI publishing workflow via GitHub Releases using trusted publishers (OIDC).
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- **BREAKING**: Renamed `type` parameter to `note_type` in `add_note()` and `ticket_type` in `edit_ticket()` to avoid shadowing the Python builtin.
|
|
25
|
+
- **BREAKING**: Renamed `search_ticket()` to `search_tickets()` with snake_case parameters (`from_user_id`, `agent_id`, `ticket_type`, `max_results`, `min_date`, `max_date`). All parameters are now keyword-only.
|
|
26
|
+
- **BREAKING**: API errors now raise `APIError` instead of returning `None`.
|
|
27
|
+
- **BREAKING**: `get_ticket_history()` now returns a `list[dict]` of parsed notes instead of a formatted JSON string.
|
|
28
|
+
- Replaced all `print()` calls with `logging` — the SDK no longer writes to stdout.
|
|
29
|
+
- `cert_path` is now optional (defaults to standard certificate verification).
|
|
30
|
+
- Internal request method renamed from `make_request` to `_request`.
|
|
31
|
+
|
|
32
|
+
### Removed
|
|
33
|
+
|
|
34
|
+
- `pretty_print_response()` — libraries should not print to stdout; use `json.dumps(response, indent=2)` if needed.
|
|
35
|
+
- `usage_decorator` — replaced by proper type annotations and exception handling.
|
|
36
|
+
- Hard-coded `time.sleep(1)` in `get_ticket_history()`.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Daniel Brandao
|
|
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,260 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lansweeper-helpdesk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for the Lansweeper Helpdesk API — create, search, and manage helpdesk tickets programmatically.
|
|
5
|
+
Project-URL: Homepage, https://github.com/ds-brandao/Lansweeper.Helpdesk-Python
|
|
6
|
+
Project-URL: Documentation, https://github.com/ds-brandao/Lansweeper.Helpdesk-Python#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/ds-brandao/Lansweeper.Helpdesk-Python
|
|
8
|
+
Project-URL: Issues, https://github.com/ds-brandao/Lansweeper.Helpdesk-Python/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/ds-brandao/Lansweeper.Helpdesk-Python/blob/main/CHANGELOG.md
|
|
10
|
+
Author: Daniel Brandao
|
|
11
|
+
License: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: api,helpdesk,it-service-management,itsm,lansweeper,sdk,ticketing
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: System Administrators
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Topic :: System :: Systems Administration
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Requires-Dist: beautifulsoup4>=4.12
|
|
29
|
+
Requires-Dist: requests>=2.28
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: build>=1.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: responses>=0.23; extra == 'dev'
|
|
36
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
37
|
+
Requires-Dist: types-beautifulsoup4>=4.12; extra == 'dev'
|
|
38
|
+
Requires-Dist: types-requests>=2.31; extra == 'dev'
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
|
|
41
|
+
# lansweeper-helpdesk
|
|
42
|
+
|
|
43
|
+
[](https://github.com/ds-brandao/Lansweeper.Helpdesk-Python/actions/workflows/ci.yml)
|
|
44
|
+
[](https://pypi.org/project/lansweeper-helpdesk/)
|
|
45
|
+
[](https://pypi.org/project/lansweeper-helpdesk/)
|
|
46
|
+
[](https://opensource.org/licenses/MIT)
|
|
47
|
+
|
|
48
|
+
A Python SDK for the [Lansweeper Helpdesk API](https://www.lansweeper.com/). Create, retrieve, search, and manage helpdesk tickets programmatically.
|
|
49
|
+
|
|
50
|
+
> **Note:** The Lansweeper Helpdesk API appears to be unmaintained and may be deprecated in the future. This SDK wraps the existing API as-is.
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install lansweeper-helpdesk
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from lansweeper_helpdesk import HelpdeskAPI
|
|
62
|
+
|
|
63
|
+
api = HelpdeskAPI(
|
|
64
|
+
base_url="https://your-helpdesk-url:443/api.aspx",
|
|
65
|
+
api_key="your-api-key",
|
|
66
|
+
cert_path="/path/to/cert.pem", # optional
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
# Create a ticket
|
|
70
|
+
ticket = api.create_ticket(
|
|
71
|
+
subject="Network Issue",
|
|
72
|
+
description="Cannot reach internal network",
|
|
73
|
+
email="user@example.com",
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
# Get ticket details (HTML is auto-stripped)
|
|
77
|
+
ticket = api.get_ticket("12345")
|
|
78
|
+
print(ticket["Description"])
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## API Reference
|
|
82
|
+
|
|
83
|
+
### `HelpdeskAPI(base_url, api_key, cert_path=None)`
|
|
84
|
+
|
|
85
|
+
Initialize the client.
|
|
86
|
+
|
|
87
|
+
| Parameter | Type | Description |
|
|
88
|
+
|-------------|-----------------|----------------------------------------------------|
|
|
89
|
+
| `base_url` | `str` | Base URL of the Lansweeper Helpdesk API |
|
|
90
|
+
| `api_key` | `str` | API key for authentication |
|
|
91
|
+
| `cert_path` | `str` or `None` | Path to SSL certificate file (optional) |
|
|
92
|
+
|
|
93
|
+
### Ticket Operations
|
|
94
|
+
|
|
95
|
+
#### `create_ticket(subject, description, email) -> dict`
|
|
96
|
+
|
|
97
|
+
Create a new helpdesk ticket.
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
api.create_ticket(
|
|
101
|
+
subject="Printer not working",
|
|
102
|
+
description="Office printer on floor 3 is offline",
|
|
103
|
+
email="user@company.com",
|
|
104
|
+
)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### `get_ticket(ticket_id) -> dict`
|
|
108
|
+
|
|
109
|
+
Retrieve ticket details. HTML in the `Description` field is automatically converted to plain text.
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
ticket = api.get_ticket("12345")
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### `get_ticket_history(ticket_id) -> list[dict]`
|
|
116
|
+
|
|
117
|
+
Get all notes for a ticket. HTML content in note text fields is auto-stripped.
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
notes = api.get_ticket_history("12345")
|
|
121
|
+
for note in notes:
|
|
122
|
+
print(note["Text"])
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### `edit_ticket(ticket_id, state, ticket_type, email) -> dict`
|
|
126
|
+
|
|
127
|
+
Update a ticket's state and type.
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
api.edit_ticket(
|
|
131
|
+
ticket_id="12345",
|
|
132
|
+
state="Closed",
|
|
133
|
+
ticket_type="Hardware Repair",
|
|
134
|
+
email="agent@company.com",
|
|
135
|
+
)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Notes
|
|
139
|
+
|
|
140
|
+
#### `add_note(ticket_id, text, email, note_type="Public") -> dict`
|
|
141
|
+
|
|
142
|
+
Add a note to a ticket. Use `note_type="Internal"` for agent-only notes.
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
api.add_note(
|
|
146
|
+
ticket_id="12345",
|
|
147
|
+
text="Router restart resolved the issue",
|
|
148
|
+
email="agent@company.com",
|
|
149
|
+
note_type="Internal",
|
|
150
|
+
)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Search
|
|
154
|
+
|
|
155
|
+
#### `search_tickets(*, state, from_user_id, agent_id, description, subject, ticket_type, max_results, min_date, max_date) -> dict`
|
|
156
|
+
|
|
157
|
+
Search tickets with optional filters. All parameters are keyword-only and optional.
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
results = api.search_tickets(
|
|
161
|
+
state="Open",
|
|
162
|
+
ticket_type="Hardware Repair",
|
|
163
|
+
max_results=50,
|
|
164
|
+
min_date="2024-01-01",
|
|
165
|
+
max_date="2024-12-31",
|
|
166
|
+
)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
#### `get_user(email) -> dict`
|
|
170
|
+
|
|
171
|
+
Look up a user by email address.
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
user = api.get_user("user@company.com")
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Enums
|
|
178
|
+
|
|
179
|
+
The SDK provides convenience enums for common values:
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from lansweeper_helpdesk import TicketState, NoteType
|
|
183
|
+
|
|
184
|
+
api.search_tickets(state=TicketState.OPEN)
|
|
185
|
+
api.add_note("12345", "note text", "a@b.com", note_type=NoteType.INTERNAL)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Error Handling
|
|
189
|
+
|
|
190
|
+
All API methods raise typed exceptions instead of returning `None`:
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
from lansweeper_helpdesk import HelpdeskAPI, APIError, ConfigurationError
|
|
194
|
+
|
|
195
|
+
try:
|
|
196
|
+
api = HelpdeskAPI(base_url="", api_key="key")
|
|
197
|
+
except ConfigurationError as e:
|
|
198
|
+
print(f"Bad config: {e}")
|
|
199
|
+
|
|
200
|
+
try:
|
|
201
|
+
ticket = api.get_ticket("99999")
|
|
202
|
+
except APIError as e:
|
|
203
|
+
print(f"API error (HTTP {e.status_code}): {e}")
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
| Exception | When |
|
|
207
|
+
|------------------------|----------------------------------------------------|
|
|
208
|
+
| `HelpdeskError` | Base class for all SDK exceptions |
|
|
209
|
+
| `ConfigurationError` | Invalid client configuration |
|
|
210
|
+
| `APIError` | HTTP or API-level error (has `.status_code`) |
|
|
211
|
+
| `TicketNotFoundError` | Requested ticket does not exist |
|
|
212
|
+
|
|
213
|
+
## Configuration
|
|
214
|
+
|
|
215
|
+
You can load credentials from a JSON config file:
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
import json
|
|
219
|
+
from lansweeper_helpdesk import HelpdeskAPI
|
|
220
|
+
|
|
221
|
+
with open("config/config.json") as f:
|
|
222
|
+
config = json.load(f)
|
|
223
|
+
|
|
224
|
+
api = HelpdeskAPI(**config)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Example `config/config.json`:
|
|
228
|
+
|
|
229
|
+
```json
|
|
230
|
+
{
|
|
231
|
+
"base_url": "https://your-helpdesk-url:443/api.aspx",
|
|
232
|
+
"api_key": "your-api-key-here",
|
|
233
|
+
"cert_path": "path/to/your/certificate.pem"
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Development
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
# Clone and install in dev mode
|
|
241
|
+
git clone https://github.com/ds-brandao/Lansweeper.Helpdesk-Python.git
|
|
242
|
+
cd Lansweeper.Helpdesk-Python
|
|
243
|
+
pip install -e ".[dev]"
|
|
244
|
+
|
|
245
|
+
# Run tests
|
|
246
|
+
pytest --cov
|
|
247
|
+
|
|
248
|
+
# Lint & format
|
|
249
|
+
ruff check src/ tests/
|
|
250
|
+
ruff format src/ tests/
|
|
251
|
+
|
|
252
|
+
# Type check
|
|
253
|
+
mypy src/
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for full guidelines.
|
|
257
|
+
|
|
258
|
+
## License
|
|
259
|
+
|
|
260
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# lansweeper-helpdesk
|
|
2
|
+
|
|
3
|
+
[](https://github.com/ds-brandao/Lansweeper.Helpdesk-Python/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/lansweeper-helpdesk/)
|
|
5
|
+
[](https://pypi.org/project/lansweeper-helpdesk/)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
A Python SDK for the [Lansweeper Helpdesk API](https://www.lansweeper.com/). Create, retrieve, search, and manage helpdesk tickets programmatically.
|
|
9
|
+
|
|
10
|
+
> **Note:** The Lansweeper Helpdesk API appears to be unmaintained and may be deprecated in the future. This SDK wraps the existing API as-is.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install lansweeper-helpdesk
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from lansweeper_helpdesk import HelpdeskAPI
|
|
22
|
+
|
|
23
|
+
api = HelpdeskAPI(
|
|
24
|
+
base_url="https://your-helpdesk-url:443/api.aspx",
|
|
25
|
+
api_key="your-api-key",
|
|
26
|
+
cert_path="/path/to/cert.pem", # optional
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Create a ticket
|
|
30
|
+
ticket = api.create_ticket(
|
|
31
|
+
subject="Network Issue",
|
|
32
|
+
description="Cannot reach internal network",
|
|
33
|
+
email="user@example.com",
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# Get ticket details (HTML is auto-stripped)
|
|
37
|
+
ticket = api.get_ticket("12345")
|
|
38
|
+
print(ticket["Description"])
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## API Reference
|
|
42
|
+
|
|
43
|
+
### `HelpdeskAPI(base_url, api_key, cert_path=None)`
|
|
44
|
+
|
|
45
|
+
Initialize the client.
|
|
46
|
+
|
|
47
|
+
| Parameter | Type | Description |
|
|
48
|
+
|-------------|-----------------|----------------------------------------------------|
|
|
49
|
+
| `base_url` | `str` | Base URL of the Lansweeper Helpdesk API |
|
|
50
|
+
| `api_key` | `str` | API key for authentication |
|
|
51
|
+
| `cert_path` | `str` or `None` | Path to SSL certificate file (optional) |
|
|
52
|
+
|
|
53
|
+
### Ticket Operations
|
|
54
|
+
|
|
55
|
+
#### `create_ticket(subject, description, email) -> dict`
|
|
56
|
+
|
|
57
|
+
Create a new helpdesk ticket.
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
api.create_ticket(
|
|
61
|
+
subject="Printer not working",
|
|
62
|
+
description="Office printer on floor 3 is offline",
|
|
63
|
+
email="user@company.com",
|
|
64
|
+
)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### `get_ticket(ticket_id) -> dict`
|
|
68
|
+
|
|
69
|
+
Retrieve ticket details. HTML in the `Description` field is automatically converted to plain text.
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
ticket = api.get_ticket("12345")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### `get_ticket_history(ticket_id) -> list[dict]`
|
|
76
|
+
|
|
77
|
+
Get all notes for a ticket. HTML content in note text fields is auto-stripped.
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
notes = api.get_ticket_history("12345")
|
|
81
|
+
for note in notes:
|
|
82
|
+
print(note["Text"])
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### `edit_ticket(ticket_id, state, ticket_type, email) -> dict`
|
|
86
|
+
|
|
87
|
+
Update a ticket's state and type.
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
api.edit_ticket(
|
|
91
|
+
ticket_id="12345",
|
|
92
|
+
state="Closed",
|
|
93
|
+
ticket_type="Hardware Repair",
|
|
94
|
+
email="agent@company.com",
|
|
95
|
+
)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Notes
|
|
99
|
+
|
|
100
|
+
#### `add_note(ticket_id, text, email, note_type="Public") -> dict`
|
|
101
|
+
|
|
102
|
+
Add a note to a ticket. Use `note_type="Internal"` for agent-only notes.
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
api.add_note(
|
|
106
|
+
ticket_id="12345",
|
|
107
|
+
text="Router restart resolved the issue",
|
|
108
|
+
email="agent@company.com",
|
|
109
|
+
note_type="Internal",
|
|
110
|
+
)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Search
|
|
114
|
+
|
|
115
|
+
#### `search_tickets(*, state, from_user_id, agent_id, description, subject, ticket_type, max_results, min_date, max_date) -> dict`
|
|
116
|
+
|
|
117
|
+
Search tickets with optional filters. All parameters are keyword-only and optional.
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
results = api.search_tickets(
|
|
121
|
+
state="Open",
|
|
122
|
+
ticket_type="Hardware Repair",
|
|
123
|
+
max_results=50,
|
|
124
|
+
min_date="2024-01-01",
|
|
125
|
+
max_date="2024-12-31",
|
|
126
|
+
)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### `get_user(email) -> dict`
|
|
130
|
+
|
|
131
|
+
Look up a user by email address.
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
user = api.get_user("user@company.com")
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Enums
|
|
138
|
+
|
|
139
|
+
The SDK provides convenience enums for common values:
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from lansweeper_helpdesk import TicketState, NoteType
|
|
143
|
+
|
|
144
|
+
api.search_tickets(state=TicketState.OPEN)
|
|
145
|
+
api.add_note("12345", "note text", "a@b.com", note_type=NoteType.INTERNAL)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Error Handling
|
|
149
|
+
|
|
150
|
+
All API methods raise typed exceptions instead of returning `None`:
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from lansweeper_helpdesk import HelpdeskAPI, APIError, ConfigurationError
|
|
154
|
+
|
|
155
|
+
try:
|
|
156
|
+
api = HelpdeskAPI(base_url="", api_key="key")
|
|
157
|
+
except ConfigurationError as e:
|
|
158
|
+
print(f"Bad config: {e}")
|
|
159
|
+
|
|
160
|
+
try:
|
|
161
|
+
ticket = api.get_ticket("99999")
|
|
162
|
+
except APIError as e:
|
|
163
|
+
print(f"API error (HTTP {e.status_code}): {e}")
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
| Exception | When |
|
|
167
|
+
|------------------------|----------------------------------------------------|
|
|
168
|
+
| `HelpdeskError` | Base class for all SDK exceptions |
|
|
169
|
+
| `ConfigurationError` | Invalid client configuration |
|
|
170
|
+
| `APIError` | HTTP or API-level error (has `.status_code`) |
|
|
171
|
+
| `TicketNotFoundError` | Requested ticket does not exist |
|
|
172
|
+
|
|
173
|
+
## Configuration
|
|
174
|
+
|
|
175
|
+
You can load credentials from a JSON config file:
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
import json
|
|
179
|
+
from lansweeper_helpdesk import HelpdeskAPI
|
|
180
|
+
|
|
181
|
+
with open("config/config.json") as f:
|
|
182
|
+
config = json.load(f)
|
|
183
|
+
|
|
184
|
+
api = HelpdeskAPI(**config)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Example `config/config.json`:
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"base_url": "https://your-helpdesk-url:443/api.aspx",
|
|
192
|
+
"api_key": "your-api-key-here",
|
|
193
|
+
"cert_path": "path/to/your/certificate.pem"
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Development
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Clone and install in dev mode
|
|
201
|
+
git clone https://github.com/ds-brandao/Lansweeper.Helpdesk-Python.git
|
|
202
|
+
cd Lansweeper.Helpdesk-Python
|
|
203
|
+
pip install -e ".[dev]"
|
|
204
|
+
|
|
205
|
+
# Run tests
|
|
206
|
+
pytest --cov
|
|
207
|
+
|
|
208
|
+
# Lint & format
|
|
209
|
+
ruff check src/ tests/
|
|
210
|
+
ruff format src/ tests/
|
|
211
|
+
|
|
212
|
+
# Type check
|
|
213
|
+
mypy src/
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for full guidelines.
|
|
217
|
+
|
|
218
|
+
## License
|
|
219
|
+
|
|
220
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "lansweeper-helpdesk"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Python SDK for the Lansweeper Helpdesk API — create, search, and manage helpdesk tickets programmatically."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Daniel Brandao" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["lansweeper", "helpdesk", "api", "sdk", "itsm", "ticketing", "it-service-management"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Intended Audience :: System Administrators",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
28
|
+
"Topic :: System :: Systems Administration",
|
|
29
|
+
"Typing :: Typed",
|
|
30
|
+
]
|
|
31
|
+
dependencies = [
|
|
32
|
+
"requests>=2.28",
|
|
33
|
+
"beautifulsoup4>=4.12",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://github.com/ds-brandao/Lansweeper.Helpdesk-Python"
|
|
38
|
+
Documentation = "https://github.com/ds-brandao/Lansweeper.Helpdesk-Python#readme"
|
|
39
|
+
Repository = "https://github.com/ds-brandao/Lansweeper.Helpdesk-Python"
|
|
40
|
+
Issues = "https://github.com/ds-brandao/Lansweeper.Helpdesk-Python/issues"
|
|
41
|
+
Changelog = "https://github.com/ds-brandao/Lansweeper.Helpdesk-Python/blob/main/CHANGELOG.md"
|
|
42
|
+
|
|
43
|
+
[project.optional-dependencies]
|
|
44
|
+
dev = [
|
|
45
|
+
"pytest>=7.0",
|
|
46
|
+
"pytest-cov>=4.0",
|
|
47
|
+
"responses>=0.23",
|
|
48
|
+
"ruff>=0.4",
|
|
49
|
+
"mypy>=1.10",
|
|
50
|
+
"types-requests>=2.31",
|
|
51
|
+
"types-beautifulsoup4>=4.12",
|
|
52
|
+
"build>=1.0",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
[tool.hatch.version]
|
|
56
|
+
path = "src/lansweeper_helpdesk/__init__.py"
|
|
57
|
+
|
|
58
|
+
[tool.hatch.build.targets.wheel]
|
|
59
|
+
packages = ["src/lansweeper_helpdesk"]
|
|
60
|
+
|
|
61
|
+
[tool.hatch.build.targets.sdist]
|
|
62
|
+
include = [
|
|
63
|
+
"src/",
|
|
64
|
+
"tests/",
|
|
65
|
+
"LICENSE",
|
|
66
|
+
"README.md",
|
|
67
|
+
"CHANGELOG.md",
|
|
68
|
+
"pyproject.toml",
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
[tool.ruff]
|
|
72
|
+
target-version = "py310"
|
|
73
|
+
line-length = 120
|
|
74
|
+
|
|
75
|
+
[tool.ruff.lint]
|
|
76
|
+
select = ["E", "F", "I", "N", "W", "UP", "B", "SIM"]
|
|
77
|
+
|
|
78
|
+
[tool.mypy]
|
|
79
|
+
python_version = "3.10"
|
|
80
|
+
strict = true
|
|
81
|
+
warn_return_any = true
|
|
82
|
+
warn_unused_configs = true
|
|
83
|
+
|
|
84
|
+
[tool.pytest.ini_options]
|
|
85
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Lansweeper Helpdesk API SDK.
|
|
2
|
+
|
|
3
|
+
A Python client for creating, retrieving, searching, and managing
|
|
4
|
+
tickets in the Lansweeper Helpdesk system.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from lansweeper_helpdesk.client import HelpdeskAPI
|
|
8
|
+
from lansweeper_helpdesk.exceptions import (
|
|
9
|
+
APIError,
|
|
10
|
+
ConfigurationError,
|
|
11
|
+
HelpdeskError,
|
|
12
|
+
TicketNotFoundError,
|
|
13
|
+
)
|
|
14
|
+
from lansweeper_helpdesk.types import NoteType, TicketState
|
|
15
|
+
|
|
16
|
+
__version__ = "0.1.0"
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"HelpdeskAPI",
|
|
20
|
+
"APIError",
|
|
21
|
+
"ConfigurationError",
|
|
22
|
+
"HelpdeskError",
|
|
23
|
+
"TicketNotFoundError",
|
|
24
|
+
"NoteType",
|
|
25
|
+
"TicketState",
|
|
26
|
+
"__version__",
|
|
27
|
+
]
|