python-zendesk-sdk 0.8.0__tar.gz → 0.11.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.
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/.gitignore +1 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/PKG-INFO +41 -5
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/README.md +40 -4
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/examples/enriched_tickets.py +27 -0
- python_zendesk_sdk-0.11.0/examples/organizations.py +110 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/pyproject.toml +1 -1
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/__init__.py +1 -1
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/client.py +17 -0
- python_zendesk_sdk-0.11.0/src/zendesk_sdk/clients/organizations.py +353 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/clients/tickets.py +93 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/tests/test_clients.py +249 -1
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/tests/test_package_import.py +1 -1
- python_zendesk_sdk-0.8.0/src/zendesk_sdk/clients/organizations.py +0 -106
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/.flake8 +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/.github/workflows/publish.yml +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/.python-version +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/LICENSE +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/context7.json +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/examples/basic_usage.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/examples/caching.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/examples/error_handling.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/examples/groups.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/examples/help_center.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/examples/pagination_example.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/examples/search.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/examples/users.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/clients/__init__.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/clients/attachments.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/clients/base.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/clients/groups.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/clients/help_center/__init__.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/clients/help_center/articles.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/clients/help_center/categories.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/clients/help_center/sections.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/clients/search.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/clients/ticket_fields.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/clients/users.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/config.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/exceptions.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/http_client.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/models/__init__.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/models/base.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/models/comment.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/models/enriched_ticket.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/models/group.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/models/help_center.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/models/organization.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/models/search.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/models/ticket.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/models/user.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/src/zendesk_sdk/pagination.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/tests/__init__.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/tests/test_client.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/tests/test_config.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/tests/test_exceptions.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/tests/test_help_center_client.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/tests/test_http_client.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/tests/test_models.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/tests/test_pagination.py +0 -0
- {python_zendesk_sdk-0.8.0 → python_zendesk_sdk-0.11.0}/tests/test_search_query_config.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-zendesk-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0
|
|
4
4
|
Summary: Modern Python SDK for Zendesk API
|
|
5
5
|
Project-URL: Homepage, https://github.com/bormog/python-zendesk-sdk
|
|
6
6
|
Project-URL: Repository, https://github.com/bormog/python-zendesk-sdk
|
|
@@ -230,8 +230,32 @@ user = await client.users.merge(source_id, target_id) # Merge into target
|
|
|
230
230
|
|
|
231
231
|
### Organizations
|
|
232
232
|
```python
|
|
233
|
-
|
|
233
|
+
# Read
|
|
234
|
+
org = await client.organizations.get(org_id) # Get organization by ID (cached)
|
|
234
235
|
paginator = client.organizations.list() # List organizations (paginator)
|
|
236
|
+
|
|
237
|
+
# Create
|
|
238
|
+
org = await client.organizations.create(
|
|
239
|
+
name="Acme Corp",
|
|
240
|
+
domain_names=["acme.com"],
|
|
241
|
+
tags=["enterprise"],
|
|
242
|
+
organization_fields={"plan": "premium"},
|
|
243
|
+
)
|
|
244
|
+
org = await client.organizations.create_or_update( # Upsert by external_id
|
|
245
|
+
name="Acme Corp",
|
|
246
|
+
external_id="acme-123",
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
# Update
|
|
250
|
+
org = await client.organizations.update(
|
|
251
|
+
org_id,
|
|
252
|
+
name="Acme Corporation",
|
|
253
|
+
tags=["enterprise", "vip"],
|
|
254
|
+
organization_fields={"plan": "enterprise"},
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
# Delete
|
|
258
|
+
await client.organizations.delete(org_id)
|
|
235
259
|
```
|
|
236
260
|
|
|
237
261
|
### Groups
|
|
@@ -265,6 +289,7 @@ await client.groups.delete(group_id)
|
|
|
265
289
|
```python
|
|
266
290
|
# Read
|
|
267
291
|
ticket = await client.tickets.get(ticket_id) # Get ticket by ID
|
|
292
|
+
tickets = await client.tickets.get_many([id1, id2]) # Get multiple tickets (batch)
|
|
268
293
|
paginator = client.tickets.list() # List tickets (paginator)
|
|
269
294
|
paginator = client.tickets.for_user(user_id) # User's tickets (paginator)
|
|
270
295
|
paginator = client.tickets.for_organization(org_id) # Org's tickets (paginator)
|
|
@@ -294,9 +319,16 @@ await client.tickets.delete(ticket_id)
|
|
|
294
319
|
### Comments (nested under tickets)
|
|
295
320
|
```python
|
|
296
321
|
paginator = client.tickets.comments.list(ticket_id) # List comments (paginator)
|
|
322
|
+
result = await client.tickets.comments.get_last(ticket_id) # Last comment + author
|
|
297
323
|
ticket = await client.tickets.comments.add(ticket_id, body, public=False)
|
|
298
324
|
await client.tickets.comments.make_private(ticket_id, comment_id)
|
|
299
325
|
comment = await client.tickets.comments.redact(ticket_id, comment_id, text)
|
|
326
|
+
|
|
327
|
+
# Get last comment with author (single API call)
|
|
328
|
+
result = await client.tickets.comments.get_last(ticket_id)
|
|
329
|
+
if result:
|
|
330
|
+
comment, author = result
|
|
331
|
+
print(f"{author.name}: {comment.body}")
|
|
300
332
|
```
|
|
301
333
|
|
|
302
334
|
### Tags (nested under tickets)
|
|
@@ -327,9 +359,12 @@ Load tickets with all related data (comments, users, field definitions) in minim
|
|
|
327
359
|
```python
|
|
328
360
|
from zendesk_sdk import SearchQueryConfig
|
|
329
361
|
|
|
330
|
-
# Get ticket with all related data
|
|
362
|
+
# Get single ticket with all related data
|
|
331
363
|
enriched = await client.tickets.get_enriched(12345)
|
|
332
364
|
|
|
365
|
+
# Batch: get multiple enriched tickets (much faster than calling get_enriched in a loop)
|
|
366
|
+
enriched_list = await client.tickets.get_many_enriched([12345, 12346, 12347])
|
|
367
|
+
|
|
333
368
|
print(f"Ticket: {enriched.ticket.subject}")
|
|
334
369
|
print(f"Requester: {enriched.requester.name}")
|
|
335
370
|
print(f"Assignee: {enriched.assignee.name if enriched.assignee else 'Unassigned'}")
|
|
@@ -489,7 +524,7 @@ Access Help Center (Guide) via `client.help_center` namespace:
|
|
|
489
524
|
```python
|
|
490
525
|
cat = await client.help_center.categories.get(category_id)
|
|
491
526
|
paginator = client.help_center.categories.list() # Paginator
|
|
492
|
-
cat = await client.help_center.categories.create(name, description)
|
|
527
|
+
cat = await client.help_center.categories.create(name, description=description)
|
|
493
528
|
cat = await client.help_center.categories.update(category_id, name=new_name)
|
|
494
529
|
await client.help_center.categories.delete(category_id, force=True)
|
|
495
530
|
```
|
|
@@ -499,7 +534,7 @@ await client.help_center.categories.delete(category_id, force=True)
|
|
|
499
534
|
sec = await client.help_center.sections.get(section_id)
|
|
500
535
|
paginator = client.help_center.sections.list() # Paginator
|
|
501
536
|
paginator = client.help_center.sections.for_category(category_id)
|
|
502
|
-
sec = await client.help_center.sections.create(category_id, name, description)
|
|
537
|
+
sec = await client.help_center.sections.create(category_id, name, description=description)
|
|
503
538
|
sec = await client.help_center.sections.update(section_id, name=new_name)
|
|
504
539
|
await client.help_center.sections.delete(section_id, force=True)
|
|
505
540
|
```
|
|
@@ -675,6 +710,7 @@ client.users.get.cache_invalidate(user_id)
|
|
|
675
710
|
See the `examples/` directory for complete usage examples:
|
|
676
711
|
- `basic_usage.py` - Basic configuration and API operations
|
|
677
712
|
- `users.py` - Users CRUD (create, update, delete, suspend, passwords)
|
|
713
|
+
- `organizations.py` - Organizations CRUD (create, update, delete, upsert)
|
|
678
714
|
- `groups.py` - Groups CRUD (create, update, delete, list)
|
|
679
715
|
- `search.py` - Type-safe search with SearchQueryConfig
|
|
680
716
|
- `pagination_example.py` - Working with paginated results
|
|
@@ -192,8 +192,32 @@ user = await client.users.merge(source_id, target_id) # Merge into target
|
|
|
192
192
|
|
|
193
193
|
### Organizations
|
|
194
194
|
```python
|
|
195
|
-
|
|
195
|
+
# Read
|
|
196
|
+
org = await client.organizations.get(org_id) # Get organization by ID (cached)
|
|
196
197
|
paginator = client.organizations.list() # List organizations (paginator)
|
|
198
|
+
|
|
199
|
+
# Create
|
|
200
|
+
org = await client.organizations.create(
|
|
201
|
+
name="Acme Corp",
|
|
202
|
+
domain_names=["acme.com"],
|
|
203
|
+
tags=["enterprise"],
|
|
204
|
+
organization_fields={"plan": "premium"},
|
|
205
|
+
)
|
|
206
|
+
org = await client.organizations.create_or_update( # Upsert by external_id
|
|
207
|
+
name="Acme Corp",
|
|
208
|
+
external_id="acme-123",
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
# Update
|
|
212
|
+
org = await client.organizations.update(
|
|
213
|
+
org_id,
|
|
214
|
+
name="Acme Corporation",
|
|
215
|
+
tags=["enterprise", "vip"],
|
|
216
|
+
organization_fields={"plan": "enterprise"},
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
# Delete
|
|
220
|
+
await client.organizations.delete(org_id)
|
|
197
221
|
```
|
|
198
222
|
|
|
199
223
|
### Groups
|
|
@@ -227,6 +251,7 @@ await client.groups.delete(group_id)
|
|
|
227
251
|
```python
|
|
228
252
|
# Read
|
|
229
253
|
ticket = await client.tickets.get(ticket_id) # Get ticket by ID
|
|
254
|
+
tickets = await client.tickets.get_many([id1, id2]) # Get multiple tickets (batch)
|
|
230
255
|
paginator = client.tickets.list() # List tickets (paginator)
|
|
231
256
|
paginator = client.tickets.for_user(user_id) # User's tickets (paginator)
|
|
232
257
|
paginator = client.tickets.for_organization(org_id) # Org's tickets (paginator)
|
|
@@ -256,9 +281,16 @@ await client.tickets.delete(ticket_id)
|
|
|
256
281
|
### Comments (nested under tickets)
|
|
257
282
|
```python
|
|
258
283
|
paginator = client.tickets.comments.list(ticket_id) # List comments (paginator)
|
|
284
|
+
result = await client.tickets.comments.get_last(ticket_id) # Last comment + author
|
|
259
285
|
ticket = await client.tickets.comments.add(ticket_id, body, public=False)
|
|
260
286
|
await client.tickets.comments.make_private(ticket_id, comment_id)
|
|
261
287
|
comment = await client.tickets.comments.redact(ticket_id, comment_id, text)
|
|
288
|
+
|
|
289
|
+
# Get last comment with author (single API call)
|
|
290
|
+
result = await client.tickets.comments.get_last(ticket_id)
|
|
291
|
+
if result:
|
|
292
|
+
comment, author = result
|
|
293
|
+
print(f"{author.name}: {comment.body}")
|
|
262
294
|
```
|
|
263
295
|
|
|
264
296
|
### Tags (nested under tickets)
|
|
@@ -289,9 +321,12 @@ Load tickets with all related data (comments, users, field definitions) in minim
|
|
|
289
321
|
```python
|
|
290
322
|
from zendesk_sdk import SearchQueryConfig
|
|
291
323
|
|
|
292
|
-
# Get ticket with all related data
|
|
324
|
+
# Get single ticket with all related data
|
|
293
325
|
enriched = await client.tickets.get_enriched(12345)
|
|
294
326
|
|
|
327
|
+
# Batch: get multiple enriched tickets (much faster than calling get_enriched in a loop)
|
|
328
|
+
enriched_list = await client.tickets.get_many_enriched([12345, 12346, 12347])
|
|
329
|
+
|
|
295
330
|
print(f"Ticket: {enriched.ticket.subject}")
|
|
296
331
|
print(f"Requester: {enriched.requester.name}")
|
|
297
332
|
print(f"Assignee: {enriched.assignee.name if enriched.assignee else 'Unassigned'}")
|
|
@@ -451,7 +486,7 @@ Access Help Center (Guide) via `client.help_center` namespace:
|
|
|
451
486
|
```python
|
|
452
487
|
cat = await client.help_center.categories.get(category_id)
|
|
453
488
|
paginator = client.help_center.categories.list() # Paginator
|
|
454
|
-
cat = await client.help_center.categories.create(name, description)
|
|
489
|
+
cat = await client.help_center.categories.create(name, description=description)
|
|
455
490
|
cat = await client.help_center.categories.update(category_id, name=new_name)
|
|
456
491
|
await client.help_center.categories.delete(category_id, force=True)
|
|
457
492
|
```
|
|
@@ -461,7 +496,7 @@ await client.help_center.categories.delete(category_id, force=True)
|
|
|
461
496
|
sec = await client.help_center.sections.get(section_id)
|
|
462
497
|
paginator = client.help_center.sections.list() # Paginator
|
|
463
498
|
paginator = client.help_center.sections.for_category(category_id)
|
|
464
|
-
sec = await client.help_center.sections.create(category_id, name, description)
|
|
499
|
+
sec = await client.help_center.sections.create(category_id, name, description=description)
|
|
465
500
|
sec = await client.help_center.sections.update(section_id, name=new_name)
|
|
466
501
|
await client.help_center.sections.delete(section_id, force=True)
|
|
467
502
|
```
|
|
@@ -637,6 +672,7 @@ client.users.get.cache_invalidate(user_id)
|
|
|
637
672
|
See the `examples/` directory for complete usage examples:
|
|
638
673
|
- `basic_usage.py` - Basic configuration and API operations
|
|
639
674
|
- `users.py` - Users CRUD (create, update, delete, suspend, passwords)
|
|
675
|
+
- `organizations.py` - Organizations CRUD (create, update, delete, upsert)
|
|
640
676
|
- `groups.py` - Groups CRUD (create, update, delete, list)
|
|
641
677
|
- `search.py` - Type-safe search with SearchQueryConfig
|
|
642
678
|
- `pagination_example.py` - Working with paginated results
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
This example demonstrates:
|
|
4
4
|
- Loading tickets with all related data (comments, users, field definitions)
|
|
5
|
+
- Batch loading multiple enriched tickets with get_many_enriched()
|
|
5
6
|
- Using EnrichedTicket for efficient data access
|
|
6
7
|
- Accessing custom field values with human-readable names
|
|
7
8
|
- Minimizing API requests with batch loading
|
|
@@ -60,6 +61,15 @@ async def main() -> None:
|
|
|
60
61
|
if field:
|
|
61
62
|
print(f"Field type: {field.type}, Required: {field.required}")
|
|
62
63
|
|
|
64
|
+
# ==================== Last comment shortcut ====================
|
|
65
|
+
|
|
66
|
+
# Get just the last comment with its author (single API call)
|
|
67
|
+
result = await client.tickets.comments.get_last(12345)
|
|
68
|
+
if result:
|
|
69
|
+
comment, author = result
|
|
70
|
+
author_name = author.name if author else "Unknown"
|
|
71
|
+
print(f"\nLast comment by {author_name}: {comment.body[:80]}")
|
|
72
|
+
|
|
63
73
|
# ==================== Comments with authors ====================
|
|
64
74
|
|
|
65
75
|
# Process comments with author information
|
|
@@ -72,6 +82,23 @@ async def main() -> None:
|
|
|
72
82
|
else:
|
|
73
83
|
print(f" - Unknown: {body_preview}")
|
|
74
84
|
|
|
85
|
+
# ==================== Batch enriched tickets ====================
|
|
86
|
+
|
|
87
|
+
# Load multiple tickets with all related data at once
|
|
88
|
+
# Much more efficient than calling get_enriched() in a loop:
|
|
89
|
+
# - 1 API call for all tickets (show_many)
|
|
90
|
+
# - 1 API call for all users (show_many)
|
|
91
|
+
# - 1 API call for field definitions
|
|
92
|
+
# - N parallel API calls for comments (one per ticket)
|
|
93
|
+
ticket_ids = [12345, 12346, 12347]
|
|
94
|
+
enriched_list = await client.tickets.get_many_enriched(ticket_ids)
|
|
95
|
+
|
|
96
|
+
print(f"\n--- Batch loaded {len(enriched_list)} enriched tickets ---")
|
|
97
|
+
for item in enriched_list:
|
|
98
|
+
print(f" #{item.ticket.id}: {item.ticket.subject}")
|
|
99
|
+
print(f" Requester: {item.requester.name if item.requester else 'N/A'}")
|
|
100
|
+
print(f" Comments: {len(item.comments)}")
|
|
101
|
+
|
|
75
102
|
# ==================== Search with enrichment ====================
|
|
76
103
|
|
|
77
104
|
# Search for tickets and load all related data
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""Organizations API example for Zendesk SDK.
|
|
2
|
+
|
|
3
|
+
This example demonstrates:
|
|
4
|
+
- Reading organizations (get, list)
|
|
5
|
+
- Creating organizations
|
|
6
|
+
- Updating organizations
|
|
7
|
+
- Upserting organizations (create_or_update)
|
|
8
|
+
- Deleting organizations
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import asyncio
|
|
12
|
+
|
|
13
|
+
from zendesk_sdk import ZendeskClient, ZendeskConfig
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
async def main() -> None:
|
|
17
|
+
config = ZendeskConfig(
|
|
18
|
+
subdomain="your-subdomain",
|
|
19
|
+
email="your-email@example.com",
|
|
20
|
+
token="your-api-token",
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
async with ZendeskClient(config) as client:
|
|
24
|
+
# ==================== Read Operations ====================
|
|
25
|
+
|
|
26
|
+
print("=== Read Operations ===")
|
|
27
|
+
|
|
28
|
+
# Get organization by ID (cached)
|
|
29
|
+
org = await client.organizations.get(12345)
|
|
30
|
+
print(f"Organization: {org.name}")
|
|
31
|
+
print(f" Domains: {org.domain_names}")
|
|
32
|
+
print(f" Tags: {org.tags}")
|
|
33
|
+
|
|
34
|
+
# List all organizations with pagination
|
|
35
|
+
print("\nAll organizations:")
|
|
36
|
+
async for org in client.organizations.list(limit=10):
|
|
37
|
+
print(f" {org.id}: {org.name}")
|
|
38
|
+
|
|
39
|
+
# Collect organizations to list
|
|
40
|
+
orgs = await client.organizations.list(limit=50).collect()
|
|
41
|
+
print(f"\nCollected {len(orgs)} organizations")
|
|
42
|
+
|
|
43
|
+
# ==================== Create Operations ====================
|
|
44
|
+
|
|
45
|
+
print("\n=== Create Operations ===")
|
|
46
|
+
|
|
47
|
+
# Create minimal organization
|
|
48
|
+
new_org = await client.organizations.create(name="Acme Corp")
|
|
49
|
+
print(f"Created organization: {new_org.id} - {new_org.name}")
|
|
50
|
+
|
|
51
|
+
# Create organization with all options
|
|
52
|
+
detailed_org = await client.organizations.create(
|
|
53
|
+
name="Enterprise Client",
|
|
54
|
+
domain_names=["enterprise.com", "enterprise.io"],
|
|
55
|
+
details="123 Business Ave, Suite 100",
|
|
56
|
+
notes="VIP customer, priority support",
|
|
57
|
+
tags=["enterprise", "vip"],
|
|
58
|
+
group_id=12345,
|
|
59
|
+
shared_tickets=True,
|
|
60
|
+
shared_comments=True,
|
|
61
|
+
organization_fields={"plan": "premium", "industry": "tech"},
|
|
62
|
+
)
|
|
63
|
+
print(f"Created detailed org: {detailed_org.id} - {detailed_org.name}")
|
|
64
|
+
|
|
65
|
+
# ==================== Update Operations ====================
|
|
66
|
+
|
|
67
|
+
print("\n=== Update Operations ===")
|
|
68
|
+
|
|
69
|
+
# Update tags only
|
|
70
|
+
updated = await client.organizations.update(
|
|
71
|
+
new_org.id,
|
|
72
|
+
tags=["enterprise", "partner"],
|
|
73
|
+
)
|
|
74
|
+
print(f"Updated tags: {updated.tags}")
|
|
75
|
+
|
|
76
|
+
# Update multiple fields
|
|
77
|
+
updated = await client.organizations.update(
|
|
78
|
+
new_org.id,
|
|
79
|
+
name="Acme Corporation",
|
|
80
|
+
domain_names=["acme.com", "acme.io"],
|
|
81
|
+
organization_fields={"plan": "enterprise"},
|
|
82
|
+
)
|
|
83
|
+
print(f"Updated org: {updated.name} (domains={updated.domain_names})")
|
|
84
|
+
|
|
85
|
+
# ==================== Upsert Operations ====================
|
|
86
|
+
|
|
87
|
+
print("\n=== Upsert Operations ===")
|
|
88
|
+
|
|
89
|
+
# Create or update by external_id
|
|
90
|
+
upserted = await client.organizations.create_or_update(
|
|
91
|
+
name="Synced Organization",
|
|
92
|
+
external_id="CRM-12345",
|
|
93
|
+
tags=["synced"],
|
|
94
|
+
organization_fields={"source": "crm"},
|
|
95
|
+
)
|
|
96
|
+
print(f"Upserted org: {upserted.id} - {upserted.name}")
|
|
97
|
+
|
|
98
|
+
# ==================== Delete Operations ====================
|
|
99
|
+
|
|
100
|
+
print("\n=== Delete Operations ===")
|
|
101
|
+
|
|
102
|
+
await client.organizations.delete(new_org.id)
|
|
103
|
+
print(f"Deleted organization: {new_org.id}")
|
|
104
|
+
|
|
105
|
+
await client.organizations.delete(detailed_org.id)
|
|
106
|
+
print(f"Deleted organization: {detailed_org.id}")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
if __name__ == "__main__":
|
|
110
|
+
asyncio.run(main())
|
|
@@ -95,6 +95,23 @@ class ZendeskClient:
|
|
|
95
95
|
Example:
|
|
96
96
|
org = await client.organizations.get(12345)
|
|
97
97
|
paginator = await client.organizations.list()
|
|
98
|
+
|
|
99
|
+
# Create an organization
|
|
100
|
+
org = await client.organizations.create(
|
|
101
|
+
name="Acme Corp", domain_names=["acme.com"]
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
# Update an organization
|
|
105
|
+
org = await client.organizations.update(12345, tags=["vip"])
|
|
106
|
+
|
|
107
|
+
# Upsert by external_id
|
|
108
|
+
org = await client.organizations.create_or_update(
|
|
109
|
+
name="Acme Corp", external_id="acme-123"
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
# Delete an organization
|
|
113
|
+
await client.organizations.delete(12345)
|
|
114
|
+
|
|
98
115
|
# For search use client.search.organizations()
|
|
99
116
|
"""
|
|
100
117
|
from .clients import OrganizationsClient
|