syllable-sdk 0.35.32__py3-none-any.whl → 0.35.34__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.
Files changed (51) hide show
  1. syllable_sdk/__init__.py +0 -1
  2. syllable_sdk/_version.py +3 -3
  3. syllable_sdk/agents.py +80 -211
  4. syllable_sdk/basesdk.py +5 -5
  5. syllable_sdk/batches.py +132 -329
  6. syllable_sdk/campaigns.py +74 -183
  7. syllable_sdk/channels.py +30 -73
  8. syllable_sdk/conversations.py +16 -37
  9. syllable_sdk/custom_messages.py +74 -183
  10. syllable_sdk/dashboards.py +64 -195
  11. syllable_sdk/data_sources.py +74 -183
  12. syllable_sdk/errors/__init__.py +55 -0
  13. syllable_sdk/errors/apierror.py +38 -0
  14. syllable_sdk/errors/httpvalidationerror.py +26 -0
  15. syllable_sdk/errors/no_response_error.py +13 -0
  16. syllable_sdk/errors/responsevalidationerror.py +25 -0
  17. syllable_sdk/errors/syllablesdkerror.py +26 -0
  18. syllable_sdk/events.py +16 -37
  19. syllable_sdk/folders.py +116 -295
  20. syllable_sdk/full_summary.py +16 -37
  21. syllable_sdk/incidents.py +84 -215
  22. syllable_sdk/insights_sdk.py +16 -41
  23. syllable_sdk/insights_tools.py +96 -253
  24. syllable_sdk/language_groups.py +86 -215
  25. syllable_sdk/latency.py +16 -37
  26. syllable_sdk/models/__init__.py +0 -8
  27. syllable_sdk/numbers.py +44 -113
  28. syllable_sdk/organizations.py +52 -139
  29. syllable_sdk/permissions.py +12 -33
  30. syllable_sdk/prompts.py +94 -251
  31. syllable_sdk/roles.py +72 -181
  32. syllable_sdk/services.py +72 -185
  33. syllable_sdk/session_debug.py +44 -109
  34. syllable_sdk/session_labels.py +44 -109
  35. syllable_sdk/sessions.py +56 -141
  36. syllable_sdk/takeouts.py +36 -99
  37. syllable_sdk/targets.py +74 -187
  38. syllable_sdk/test.py +16 -37
  39. syllable_sdk/tools.py +72 -181
  40. syllable_sdk/transcript.py +18 -39
  41. syllable_sdk/twilio.py +44 -109
  42. syllable_sdk/users.py +94 -247
  43. syllable_sdk/utils/serializers.py +3 -2
  44. syllable_sdk/utils/unmarshal_json_response.py +24 -0
  45. syllable_sdk/v1.py +94 -247
  46. syllable_sdk/workflows.py +116 -291
  47. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.34.dist-info}/METADATA +58 -45
  48. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.34.dist-info}/RECORD +49 -44
  49. syllable_sdk/models/apierror.py +0 -22
  50. syllable_sdk/models/httpvalidationerror.py +0 -21
  51. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.34.dist-info}/WHEEL +0 -0
syllable_sdk/numbers.py CHANGED
@@ -1,10 +1,11 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from syllable_sdk import models, utils
4
+ from syllable_sdk import errors, models, utils
5
5
  from syllable_sdk._hooks import HookContext
6
6
  from syllable_sdk.types import OptionalNullable, UNSET
7
7
  from syllable_sdk.utils import get_security_from_env
8
+ from syllable_sdk.utils.unmarshal_json_response import unmarshal_json_response
8
9
  from typing import Any, Mapping, Optional, Union
9
10
 
10
11
 
@@ -99,31 +100,20 @@ class Numbers(BaseSDK):
99
100
 
100
101
  response_data: Any = None
101
102
  if utils.match_response(http_res, "200", "application/json"):
102
- return utils.unmarshal_json(http_res.text, models.TwilioNumberAddResponse)
103
+ return unmarshal_json_response(models.TwilioNumberAddResponse, http_res)
103
104
  if utils.match_response(http_res, "422", "application/json"):
104
- response_data = utils.unmarshal_json(
105
- http_res.text, models.HTTPValidationErrorData
105
+ response_data = unmarshal_json_response(
106
+ errors.HTTPValidationErrorData, http_res
106
107
  )
107
- raise models.HTTPValidationError(data=response_data)
108
+ raise errors.HTTPValidationError(response_data, http_res)
108
109
  if utils.match_response(http_res, "4XX", "*"):
109
110
  http_res_text = utils.stream_to_text(http_res)
110
- raise models.APIError(
111
- "API error occurred", http_res.status_code, http_res_text, http_res
112
- )
111
+ raise errors.APIError("API error occurred", http_res, http_res_text)
113
112
  if utils.match_response(http_res, "5XX", "*"):
114
113
  http_res_text = utils.stream_to_text(http_res)
115
- raise models.APIError(
116
- "API error occurred", http_res.status_code, http_res_text, http_res
117
- )
114
+ raise errors.APIError("API error occurred", http_res, http_res_text)
118
115
 
119
- content_type = http_res.headers.get("Content-Type")
120
- http_res_text = utils.stream_to_text(http_res)
121
- raise models.APIError(
122
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
123
- http_res.status_code,
124
- http_res_text,
125
- http_res,
126
- )
116
+ raise errors.APIError("Unexpected response received", http_res)
127
117
 
128
118
  async def add_async(
129
119
  self,
@@ -213,31 +203,20 @@ class Numbers(BaseSDK):
213
203
 
214
204
  response_data: Any = None
215
205
  if utils.match_response(http_res, "200", "application/json"):
216
- return utils.unmarshal_json(http_res.text, models.TwilioNumberAddResponse)
206
+ return unmarshal_json_response(models.TwilioNumberAddResponse, http_res)
217
207
  if utils.match_response(http_res, "422", "application/json"):
218
- response_data = utils.unmarshal_json(
219
- http_res.text, models.HTTPValidationErrorData
208
+ response_data = unmarshal_json_response(
209
+ errors.HTTPValidationErrorData, http_res
220
210
  )
221
- raise models.HTTPValidationError(data=response_data)
211
+ raise errors.HTTPValidationError(response_data, http_res)
222
212
  if utils.match_response(http_res, "4XX", "*"):
223
213
  http_res_text = await utils.stream_to_text_async(http_res)
224
- raise models.APIError(
225
- "API error occurred", http_res.status_code, http_res_text, http_res
226
- )
214
+ raise errors.APIError("API error occurred", http_res, http_res_text)
227
215
  if utils.match_response(http_res, "5XX", "*"):
228
216
  http_res_text = await utils.stream_to_text_async(http_res)
229
- raise models.APIError(
230
- "API error occurred", http_res.status_code, http_res_text, http_res
231
- )
217
+ raise errors.APIError("API error occurred", http_res, http_res_text)
232
218
 
233
- content_type = http_res.headers.get("Content-Type")
234
- http_res_text = await utils.stream_to_text_async(http_res)
235
- raise models.APIError(
236
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
237
- http_res.status_code,
238
- http_res_text,
239
- http_res,
240
- )
219
+ raise errors.APIError("Unexpected response received", http_res)
241
220
 
242
221
  def update(
243
222
  self,
@@ -327,33 +306,20 @@ class Numbers(BaseSDK):
327
306
 
328
307
  response_data: Any = None
329
308
  if utils.match_response(http_res, "200", "application/json"):
330
- return utils.unmarshal_json(
331
- http_res.text, models.TwilioNumberUpdateResponse
332
- )
309
+ return unmarshal_json_response(models.TwilioNumberUpdateResponse, http_res)
333
310
  if utils.match_response(http_res, "422", "application/json"):
334
- response_data = utils.unmarshal_json(
335
- http_res.text, models.HTTPValidationErrorData
311
+ response_data = unmarshal_json_response(
312
+ errors.HTTPValidationErrorData, http_res
336
313
  )
337
- raise models.HTTPValidationError(data=response_data)
314
+ raise errors.HTTPValidationError(response_data, http_res)
338
315
  if utils.match_response(http_res, "4XX", "*"):
339
316
  http_res_text = utils.stream_to_text(http_res)
340
- raise models.APIError(
341
- "API error occurred", http_res.status_code, http_res_text, http_res
342
- )
317
+ raise errors.APIError("API error occurred", http_res, http_res_text)
343
318
  if utils.match_response(http_res, "5XX", "*"):
344
319
  http_res_text = utils.stream_to_text(http_res)
345
- raise models.APIError(
346
- "API error occurred", http_res.status_code, http_res_text, http_res
347
- )
320
+ raise errors.APIError("API error occurred", http_res, http_res_text)
348
321
 
349
- content_type = http_res.headers.get("Content-Type")
350
- http_res_text = utils.stream_to_text(http_res)
351
- raise models.APIError(
352
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
353
- http_res.status_code,
354
- http_res_text,
355
- http_res,
356
- )
322
+ raise errors.APIError("Unexpected response received", http_res)
357
323
 
358
324
  async def update_async(
359
325
  self,
@@ -443,33 +409,20 @@ class Numbers(BaseSDK):
443
409
 
444
410
  response_data: Any = None
445
411
  if utils.match_response(http_res, "200", "application/json"):
446
- return utils.unmarshal_json(
447
- http_res.text, models.TwilioNumberUpdateResponse
448
- )
412
+ return unmarshal_json_response(models.TwilioNumberUpdateResponse, http_res)
449
413
  if utils.match_response(http_res, "422", "application/json"):
450
- response_data = utils.unmarshal_json(
451
- http_res.text, models.HTTPValidationErrorData
414
+ response_data = unmarshal_json_response(
415
+ errors.HTTPValidationErrorData, http_res
452
416
  )
453
- raise models.HTTPValidationError(data=response_data)
417
+ raise errors.HTTPValidationError(response_data, http_res)
454
418
  if utils.match_response(http_res, "4XX", "*"):
455
419
  http_res_text = await utils.stream_to_text_async(http_res)
456
- raise models.APIError(
457
- "API error occurred", http_res.status_code, http_res_text, http_res
458
- )
420
+ raise errors.APIError("API error occurred", http_res, http_res_text)
459
421
  if utils.match_response(http_res, "5XX", "*"):
460
422
  http_res_text = await utils.stream_to_text_async(http_res)
461
- raise models.APIError(
462
- "API error occurred", http_res.status_code, http_res_text, http_res
463
- )
423
+ raise errors.APIError("API error occurred", http_res, http_res_text)
464
424
 
465
- content_type = http_res.headers.get("Content-Type")
466
- http_res_text = await utils.stream_to_text_async(http_res)
467
- raise models.APIError(
468
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
469
- http_res.status_code,
470
- http_res_text,
471
- http_res,
472
- )
425
+ raise errors.APIError("Unexpected response received", http_res)
473
426
 
474
427
  def list(
475
428
  self,
@@ -545,31 +498,20 @@ class Numbers(BaseSDK):
545
498
 
546
499
  response_data: Any = None
547
500
  if utils.match_response(http_res, "200", "application/json"):
548
- return utils.unmarshal_json(http_res.text, models.TwilioListNumbersResponse)
501
+ return unmarshal_json_response(models.TwilioListNumbersResponse, http_res)
549
502
  if utils.match_response(http_res, "422", "application/json"):
550
- response_data = utils.unmarshal_json(
551
- http_res.text, models.HTTPValidationErrorData
503
+ response_data = unmarshal_json_response(
504
+ errors.HTTPValidationErrorData, http_res
552
505
  )
553
- raise models.HTTPValidationError(data=response_data)
506
+ raise errors.HTTPValidationError(response_data, http_res)
554
507
  if utils.match_response(http_res, "4XX", "*"):
555
508
  http_res_text = utils.stream_to_text(http_res)
556
- raise models.APIError(
557
- "API error occurred", http_res.status_code, http_res_text, http_res
558
- )
509
+ raise errors.APIError("API error occurred", http_res, http_res_text)
559
510
  if utils.match_response(http_res, "5XX", "*"):
560
511
  http_res_text = utils.stream_to_text(http_res)
561
- raise models.APIError(
562
- "API error occurred", http_res.status_code, http_res_text, http_res
563
- )
512
+ raise errors.APIError("API error occurred", http_res, http_res_text)
564
513
 
565
- content_type = http_res.headers.get("Content-Type")
566
- http_res_text = utils.stream_to_text(http_res)
567
- raise models.APIError(
568
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
569
- http_res.status_code,
570
- http_res_text,
571
- http_res,
572
- )
514
+ raise errors.APIError("Unexpected response received", http_res)
573
515
 
574
516
  async def list_async(
575
517
  self,
@@ -645,28 +587,17 @@ class Numbers(BaseSDK):
645
587
 
646
588
  response_data: Any = None
647
589
  if utils.match_response(http_res, "200", "application/json"):
648
- return utils.unmarshal_json(http_res.text, models.TwilioListNumbersResponse)
590
+ return unmarshal_json_response(models.TwilioListNumbersResponse, http_res)
649
591
  if utils.match_response(http_res, "422", "application/json"):
650
- response_data = utils.unmarshal_json(
651
- http_res.text, models.HTTPValidationErrorData
592
+ response_data = unmarshal_json_response(
593
+ errors.HTTPValidationErrorData, http_res
652
594
  )
653
- raise models.HTTPValidationError(data=response_data)
595
+ raise errors.HTTPValidationError(response_data, http_res)
654
596
  if utils.match_response(http_res, "4XX", "*"):
655
597
  http_res_text = await utils.stream_to_text_async(http_res)
656
- raise models.APIError(
657
- "API error occurred", http_res.status_code, http_res_text, http_res
658
- )
598
+ raise errors.APIError("API error occurred", http_res, http_res_text)
659
599
  if utils.match_response(http_res, "5XX", "*"):
660
600
  http_res_text = await utils.stream_to_text_async(http_res)
661
- raise models.APIError(
662
- "API error occurred", http_res.status_code, http_res_text, http_res
663
- )
601
+ raise errors.APIError("API error occurred", http_res, http_res_text)
664
602
 
665
- content_type = http_res.headers.get("Content-Type")
666
- http_res_text = await utils.stream_to_text_async(http_res)
667
- raise models.APIError(
668
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
669
- http_res.status_code,
670
- http_res_text,
671
- http_res,
672
- )
603
+ raise errors.APIError("Unexpected response received", http_res)
@@ -1,10 +1,11 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from syllable_sdk import models, utils
4
+ from syllable_sdk import errors, models, utils
5
5
  from syllable_sdk._hooks import HookContext
6
6
  from syllable_sdk.types import BaseModel, OptionalNullable, UNSET
7
7
  from syllable_sdk.utils import get_security_from_env
8
+ from syllable_sdk.utils.unmarshal_json_response import unmarshal_json_response
8
9
  from typing import Any, Mapping, Optional, Union, cast
9
10
 
10
11
 
@@ -77,26 +78,15 @@ class Organizations(BaseSDK):
77
78
  )
78
79
 
79
80
  if utils.match_response(http_res, "200", "application/json"):
80
- return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
81
+ return unmarshal_json_response(models.OrganizationResponse, http_res)
81
82
  if utils.match_response(http_res, "4XX", "*"):
82
83
  http_res_text = utils.stream_to_text(http_res)
83
- raise models.APIError(
84
- "API error occurred", http_res.status_code, http_res_text, http_res
85
- )
84
+ raise errors.APIError("API error occurred", http_res, http_res_text)
86
85
  if utils.match_response(http_res, "5XX", "*"):
87
86
  http_res_text = utils.stream_to_text(http_res)
88
- raise models.APIError(
89
- "API error occurred", http_res.status_code, http_res_text, http_res
90
- )
87
+ raise errors.APIError("API error occurred", http_res, http_res_text)
91
88
 
92
- content_type = http_res.headers.get("Content-Type")
93
- http_res_text = utils.stream_to_text(http_res)
94
- raise models.APIError(
95
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
96
- http_res.status_code,
97
- http_res_text,
98
- http_res,
99
- )
89
+ raise errors.APIError("Unexpected response received", http_res)
100
90
 
101
91
  async def organizations_get_async(
102
92
  self,
@@ -164,26 +154,15 @@ class Organizations(BaseSDK):
164
154
  )
165
155
 
166
156
  if utils.match_response(http_res, "200", "application/json"):
167
- return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
157
+ return unmarshal_json_response(models.OrganizationResponse, http_res)
168
158
  if utils.match_response(http_res, "4XX", "*"):
169
159
  http_res_text = await utils.stream_to_text_async(http_res)
170
- raise models.APIError(
171
- "API error occurred", http_res.status_code, http_res_text, http_res
172
- )
160
+ raise errors.APIError("API error occurred", http_res, http_res_text)
173
161
  if utils.match_response(http_res, "5XX", "*"):
174
162
  http_res_text = await utils.stream_to_text_async(http_res)
175
- raise models.APIError(
176
- "API error occurred", http_res.status_code, http_res_text, http_res
177
- )
163
+ raise errors.APIError("API error occurred", http_res, http_res_text)
178
164
 
179
- content_type = http_res.headers.get("Content-Type")
180
- http_res_text = await utils.stream_to_text_async(http_res)
181
- raise models.APIError(
182
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
183
- http_res.status_code,
184
- http_res_text,
185
- http_res,
186
- )
165
+ raise errors.APIError("Unexpected response received", http_res)
187
166
 
188
167
  def update(
189
168
  self,
@@ -264,31 +243,20 @@ class Organizations(BaseSDK):
264
243
 
265
244
  response_data: Any = None
266
245
  if utils.match_response(http_res, "200", "application/json"):
267
- return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
246
+ return unmarshal_json_response(models.OrganizationResponse, http_res)
268
247
  if utils.match_response(http_res, "422", "application/json"):
269
- response_data = utils.unmarshal_json(
270
- http_res.text, models.HTTPValidationErrorData
248
+ response_data = unmarshal_json_response(
249
+ errors.HTTPValidationErrorData, http_res
271
250
  )
272
- raise models.HTTPValidationError(data=response_data)
251
+ raise errors.HTTPValidationError(response_data, http_res)
273
252
  if utils.match_response(http_res, "4XX", "*"):
274
253
  http_res_text = utils.stream_to_text(http_res)
275
- raise models.APIError(
276
- "API error occurred", http_res.status_code, http_res_text, http_res
277
- )
254
+ raise errors.APIError("API error occurred", http_res, http_res_text)
278
255
  if utils.match_response(http_res, "5XX", "*"):
279
256
  http_res_text = utils.stream_to_text(http_res)
280
- raise models.APIError(
281
- "API error occurred", http_res.status_code, http_res_text, http_res
282
- )
257
+ raise errors.APIError("API error occurred", http_res, http_res_text)
283
258
 
284
- content_type = http_res.headers.get("Content-Type")
285
- http_res_text = utils.stream_to_text(http_res)
286
- raise models.APIError(
287
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
288
- http_res.status_code,
289
- http_res_text,
290
- http_res,
291
- )
259
+ raise errors.APIError("Unexpected response received", http_res)
292
260
 
293
261
  async def update_async(
294
262
  self,
@@ -369,31 +337,20 @@ class Organizations(BaseSDK):
369
337
 
370
338
  response_data: Any = None
371
339
  if utils.match_response(http_res, "200", "application/json"):
372
- return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
340
+ return unmarshal_json_response(models.OrganizationResponse, http_res)
373
341
  if utils.match_response(http_res, "422", "application/json"):
374
- response_data = utils.unmarshal_json(
375
- http_res.text, models.HTTPValidationErrorData
342
+ response_data = unmarshal_json_response(
343
+ errors.HTTPValidationErrorData, http_res
376
344
  )
377
- raise models.HTTPValidationError(data=response_data)
345
+ raise errors.HTTPValidationError(response_data, http_res)
378
346
  if utils.match_response(http_res, "4XX", "*"):
379
347
  http_res_text = await utils.stream_to_text_async(http_res)
380
- raise models.APIError(
381
- "API error occurred", http_res.status_code, http_res_text, http_res
382
- )
348
+ raise errors.APIError("API error occurred", http_res, http_res_text)
383
349
  if utils.match_response(http_res, "5XX", "*"):
384
350
  http_res_text = await utils.stream_to_text_async(http_res)
385
- raise models.APIError(
386
- "API error occurred", http_res.status_code, http_res_text, http_res
387
- )
351
+ raise errors.APIError("API error occurred", http_res, http_res_text)
388
352
 
389
- content_type = http_res.headers.get("Content-Type")
390
- http_res_text = await utils.stream_to_text_async(http_res)
391
- raise models.APIError(
392
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
393
- http_res.status_code,
394
- http_res_text,
395
- http_res,
396
- )
353
+ raise errors.APIError("Unexpected response received", http_res)
397
354
 
398
355
  def create(
399
356
  self,
@@ -474,31 +431,20 @@ class Organizations(BaseSDK):
474
431
 
475
432
  response_data: Any = None
476
433
  if utils.match_response(http_res, "200", "application/json"):
477
- return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
434
+ return unmarshal_json_response(models.OrganizationResponse, http_res)
478
435
  if utils.match_response(http_res, "422", "application/json"):
479
- response_data = utils.unmarshal_json(
480
- http_res.text, models.HTTPValidationErrorData
436
+ response_data = unmarshal_json_response(
437
+ errors.HTTPValidationErrorData, http_res
481
438
  )
482
- raise models.HTTPValidationError(data=response_data)
439
+ raise errors.HTTPValidationError(response_data, http_res)
483
440
  if utils.match_response(http_res, "4XX", "*"):
484
441
  http_res_text = utils.stream_to_text(http_res)
485
- raise models.APIError(
486
- "API error occurred", http_res.status_code, http_res_text, http_res
487
- )
442
+ raise errors.APIError("API error occurred", http_res, http_res_text)
488
443
  if utils.match_response(http_res, "5XX", "*"):
489
444
  http_res_text = utils.stream_to_text(http_res)
490
- raise models.APIError(
491
- "API error occurred", http_res.status_code, http_res_text, http_res
492
- )
445
+ raise errors.APIError("API error occurred", http_res, http_res_text)
493
446
 
494
- content_type = http_res.headers.get("Content-Type")
495
- http_res_text = utils.stream_to_text(http_res)
496
- raise models.APIError(
497
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
498
- http_res.status_code,
499
- http_res_text,
500
- http_res,
501
- )
447
+ raise errors.APIError("Unexpected response received", http_res)
502
448
 
503
449
  async def create_async(
504
450
  self,
@@ -579,31 +525,20 @@ class Organizations(BaseSDK):
579
525
 
580
526
  response_data: Any = None
581
527
  if utils.match_response(http_res, "200", "application/json"):
582
- return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
528
+ return unmarshal_json_response(models.OrganizationResponse, http_res)
583
529
  if utils.match_response(http_res, "422", "application/json"):
584
- response_data = utils.unmarshal_json(
585
- http_res.text, models.HTTPValidationErrorData
530
+ response_data = unmarshal_json_response(
531
+ errors.HTTPValidationErrorData, http_res
586
532
  )
587
- raise models.HTTPValidationError(data=response_data)
533
+ raise errors.HTTPValidationError(response_data, http_res)
588
534
  if utils.match_response(http_res, "4XX", "*"):
589
535
  http_res_text = await utils.stream_to_text_async(http_res)
590
- raise models.APIError(
591
- "API error occurred", http_res.status_code, http_res_text, http_res
592
- )
536
+ raise errors.APIError("API error occurred", http_res, http_res_text)
593
537
  if utils.match_response(http_res, "5XX", "*"):
594
538
  http_res_text = await utils.stream_to_text_async(http_res)
595
- raise models.APIError(
596
- "API error occurred", http_res.status_code, http_res_text, http_res
597
- )
539
+ raise errors.APIError("API error occurred", http_res, http_res_text)
598
540
 
599
- content_type = http_res.headers.get("Content-Type")
600
- http_res_text = await utils.stream_to_text_async(http_res)
601
- raise models.APIError(
602
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
603
- http_res.status_code,
604
- http_res_text,
605
- http_res,
606
- )
541
+ raise errors.APIError("Unexpected response received", http_res)
607
542
 
608
543
  def delete(
609
544
  self,
@@ -686,31 +621,20 @@ class Organizations(BaseSDK):
686
621
 
687
622
  response_data: Any = None
688
623
  if utils.match_response(http_res, "200", "application/json"):
689
- return utils.unmarshal_json(http_res.text, Any)
624
+ return unmarshal_json_response(Any, http_res)
690
625
  if utils.match_response(http_res, "422", "application/json"):
691
- response_data = utils.unmarshal_json(
692
- http_res.text, models.HTTPValidationErrorData
626
+ response_data = unmarshal_json_response(
627
+ errors.HTTPValidationErrorData, http_res
693
628
  )
694
- raise models.HTTPValidationError(data=response_data)
629
+ raise errors.HTTPValidationError(response_data, http_res)
695
630
  if utils.match_response(http_res, "4XX", "*"):
696
631
  http_res_text = utils.stream_to_text(http_res)
697
- raise models.APIError(
698
- "API error occurred", http_res.status_code, http_res_text, http_res
699
- )
632
+ raise errors.APIError("API error occurred", http_res, http_res_text)
700
633
  if utils.match_response(http_res, "5XX", "*"):
701
634
  http_res_text = utils.stream_to_text(http_res)
702
- raise models.APIError(
703
- "API error occurred", http_res.status_code, http_res_text, http_res
704
- )
635
+ raise errors.APIError("API error occurred", http_res, http_res_text)
705
636
 
706
- content_type = http_res.headers.get("Content-Type")
707
- http_res_text = utils.stream_to_text(http_res)
708
- raise models.APIError(
709
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
710
- http_res.status_code,
711
- http_res_text,
712
- http_res,
713
- )
637
+ raise errors.APIError("Unexpected response received", http_res)
714
638
 
715
639
  async def delete_async(
716
640
  self,
@@ -793,28 +717,17 @@ class Organizations(BaseSDK):
793
717
 
794
718
  response_data: Any = None
795
719
  if utils.match_response(http_res, "200", "application/json"):
796
- return utils.unmarshal_json(http_res.text, Any)
720
+ return unmarshal_json_response(Any, http_res)
797
721
  if utils.match_response(http_res, "422", "application/json"):
798
- response_data = utils.unmarshal_json(
799
- http_res.text, models.HTTPValidationErrorData
722
+ response_data = unmarshal_json_response(
723
+ errors.HTTPValidationErrorData, http_res
800
724
  )
801
- raise models.HTTPValidationError(data=response_data)
725
+ raise errors.HTTPValidationError(response_data, http_res)
802
726
  if utils.match_response(http_res, "4XX", "*"):
803
727
  http_res_text = await utils.stream_to_text_async(http_res)
804
- raise models.APIError(
805
- "API error occurred", http_res.status_code, http_res_text, http_res
806
- )
728
+ raise errors.APIError("API error occurred", http_res, http_res_text)
807
729
  if utils.match_response(http_res, "5XX", "*"):
808
730
  http_res_text = await utils.stream_to_text_async(http_res)
809
- raise models.APIError(
810
- "API error occurred", http_res.status_code, http_res_text, http_res
811
- )
731
+ raise errors.APIError("API error occurred", http_res, http_res_text)
812
732
 
813
- content_type = http_res.headers.get("Content-Type")
814
- http_res_text = await utils.stream_to_text_async(http_res)
815
- raise models.APIError(
816
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
817
- http_res.status_code,
818
- http_res_text,
819
- http_res,
820
- )
733
+ raise errors.APIError("Unexpected response received", http_res)
@@ -1,10 +1,11 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from syllable_sdk import models, utils
4
+ from syllable_sdk import errors, models, utils
5
5
  from syllable_sdk._hooks import HookContext
6
6
  from syllable_sdk.types import OptionalNullable, UNSET
7
7
  from syllable_sdk.utils import get_security_from_env
8
+ from syllable_sdk.utils.unmarshal_json_response import unmarshal_json_response
8
9
  from typing import List, Mapping, Optional
9
10
 
10
11
 
@@ -77,28 +78,17 @@ class Permissions(BaseSDK):
77
78
  )
78
79
 
79
80
  if utils.match_response(http_res, "200", "application/json"):
80
- return utils.unmarshal_json(
81
- http_res.text, List[models.PermissionGroupResponse]
81
+ return unmarshal_json_response(
82
+ List[models.PermissionGroupResponse], http_res
82
83
  )
83
84
  if utils.match_response(http_res, "4XX", "*"):
84
85
  http_res_text = utils.stream_to_text(http_res)
85
- raise models.APIError(
86
- "API error occurred", http_res.status_code, http_res_text, http_res
87
- )
86
+ raise errors.APIError("API error occurred", http_res, http_res_text)
88
87
  if utils.match_response(http_res, "5XX", "*"):
89
88
  http_res_text = utils.stream_to_text(http_res)
90
- raise models.APIError(
91
- "API error occurred", http_res.status_code, http_res_text, http_res
92
- )
89
+ raise errors.APIError("API error occurred", http_res, http_res_text)
93
90
 
94
- content_type = http_res.headers.get("Content-Type")
95
- http_res_text = utils.stream_to_text(http_res)
96
- raise models.APIError(
97
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
98
- http_res.status_code,
99
- http_res_text,
100
- http_res,
101
- )
91
+ raise errors.APIError("Unexpected response received", http_res)
102
92
 
103
93
  async def list_async(
104
94
  self,
@@ -166,25 +156,14 @@ class Permissions(BaseSDK):
166
156
  )
167
157
 
168
158
  if utils.match_response(http_res, "200", "application/json"):
169
- return utils.unmarshal_json(
170
- http_res.text, List[models.PermissionGroupResponse]
159
+ return unmarshal_json_response(
160
+ List[models.PermissionGroupResponse], http_res
171
161
  )
172
162
  if utils.match_response(http_res, "4XX", "*"):
173
163
  http_res_text = await utils.stream_to_text_async(http_res)
174
- raise models.APIError(
175
- "API error occurred", http_res.status_code, http_res_text, http_res
176
- )
164
+ raise errors.APIError("API error occurred", http_res, http_res_text)
177
165
  if utils.match_response(http_res, "5XX", "*"):
178
166
  http_res_text = await utils.stream_to_text_async(http_res)
179
- raise models.APIError(
180
- "API error occurred", http_res.status_code, http_res_text, http_res
181
- )
167
+ raise errors.APIError("API error occurred", http_res, http_res_text)
182
168
 
183
- content_type = http_res.headers.get("Content-Type")
184
- http_res_text = await utils.stream_to_text_async(http_res)
185
- raise models.APIError(
186
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
187
- http_res.status_code,
188
- http_res_text,
189
- http_res,
190
- )
169
+ raise errors.APIError("Unexpected response received", http_res)