syllable-sdk 0.35.32__py3-none-any.whl → 0.35.33__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 +83 -211
  4. syllable_sdk/basesdk.py +5 -5
  5. syllable_sdk/batches.py +131 -329
  6. syllable_sdk/campaigns.py +73 -183
  7. syllable_sdk/channels.py +29 -73
  8. syllable_sdk/conversations.py +19 -37
  9. syllable_sdk/custom_messages.py +73 -183
  10. syllable_sdk/dashboards.py +67 -195
  11. syllable_sdk/data_sources.py +85 -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 +15 -37
  19. syllable_sdk/folders.py +121 -293
  20. syllable_sdk/full_summary.py +19 -37
  21. syllable_sdk/incidents.py +83 -215
  22. syllable_sdk/insights_sdk.py +17 -39
  23. syllable_sdk/insights_tools.py +97 -251
  24. syllable_sdk/language_groups.py +85 -215
  25. syllable_sdk/latency.py +19 -37
  26. syllable_sdk/models/__init__.py +0 -8
  27. syllable_sdk/numbers.py +53 -111
  28. syllable_sdk/organizations.py +51 -139
  29. syllable_sdk/permissions.py +11 -33
  30. syllable_sdk/prompts.py +95 -249
  31. syllable_sdk/roles.py +75 -181
  32. syllable_sdk/services.py +73 -183
  33. syllable_sdk/session_debug.py +43 -109
  34. syllable_sdk/session_labels.py +47 -109
  35. syllable_sdk/sessions.py +59 -141
  36. syllable_sdk/takeouts.py +35 -99
  37. syllable_sdk/targets.py +75 -185
  38. syllable_sdk/test.py +15 -37
  39. syllable_sdk/tools.py +75 -181
  40. syllable_sdk/transcript.py +17 -39
  41. syllable_sdk/twilio.py +43 -109
  42. syllable_sdk/users.py +97 -247
  43. syllable_sdk/utils/__init__.py +3 -0
  44. syllable_sdk/utils/serializers.py +21 -3
  45. syllable_sdk/v1.py +97 -247
  46. syllable_sdk/workflows.py +115 -291
  47. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/METADATA +58 -45
  48. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/RECORD +49 -45
  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.33.dist-info}/WHEEL +0 -0
syllable_sdk/numbers.py CHANGED
@@ -1,7 +1,7 @@
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
@@ -99,31 +99,22 @@ class Numbers(BaseSDK):
99
99
 
100
100
  response_data: Any = None
101
101
  if utils.match_response(http_res, "200", "application/json"):
102
- return utils.unmarshal_json(http_res.text, models.TwilioNumberAddResponse)
102
+ return utils.unmarshal_json_response(
103
+ models.TwilioNumberAddResponse, http_res
104
+ )
103
105
  if utils.match_response(http_res, "422", "application/json"):
104
- response_data = utils.unmarshal_json(
105
- http_res.text, models.HTTPValidationErrorData
106
+ response_data = utils.unmarshal_json_response(
107
+ errors.HTTPValidationErrorData, http_res
106
108
  )
107
- raise models.HTTPValidationError(data=response_data)
109
+ raise errors.HTTPValidationError(response_data, http_res)
108
110
  if utils.match_response(http_res, "4XX", "*"):
109
111
  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
- )
112
+ raise errors.APIError("API error occurred", http_res, http_res_text)
113
113
  if utils.match_response(http_res, "5XX", "*"):
114
114
  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
- )
115
+ raise errors.APIError("API error occurred", http_res, http_res_text)
118
116
 
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
- )
117
+ raise errors.APIError("Unexpected response received", http_res)
127
118
 
128
119
  async def add_async(
129
120
  self,
@@ -213,31 +204,22 @@ class Numbers(BaseSDK):
213
204
 
214
205
  response_data: Any = None
215
206
  if utils.match_response(http_res, "200", "application/json"):
216
- return utils.unmarshal_json(http_res.text, models.TwilioNumberAddResponse)
207
+ return utils.unmarshal_json_response(
208
+ models.TwilioNumberAddResponse, http_res
209
+ )
217
210
  if utils.match_response(http_res, "422", "application/json"):
218
- response_data = utils.unmarshal_json(
219
- http_res.text, models.HTTPValidationErrorData
211
+ response_data = utils.unmarshal_json_response(
212
+ errors.HTTPValidationErrorData, http_res
220
213
  )
221
- raise models.HTTPValidationError(data=response_data)
214
+ raise errors.HTTPValidationError(response_data, http_res)
222
215
  if utils.match_response(http_res, "4XX", "*"):
223
216
  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
- )
217
+ raise errors.APIError("API error occurred", http_res, http_res_text)
227
218
  if utils.match_response(http_res, "5XX", "*"):
228
219
  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
- )
220
+ raise errors.APIError("API error occurred", http_res, http_res_text)
232
221
 
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
- )
222
+ raise errors.APIError("Unexpected response received", http_res)
241
223
 
242
224
  def update(
243
225
  self,
@@ -327,33 +309,22 @@ class Numbers(BaseSDK):
327
309
 
328
310
  response_data: Any = None
329
311
  if utils.match_response(http_res, "200", "application/json"):
330
- return utils.unmarshal_json(
331
- http_res.text, models.TwilioNumberUpdateResponse
312
+ return utils.unmarshal_json_response(
313
+ models.TwilioNumberUpdateResponse, http_res
332
314
  )
333
315
  if utils.match_response(http_res, "422", "application/json"):
334
- response_data = utils.unmarshal_json(
335
- http_res.text, models.HTTPValidationErrorData
316
+ response_data = utils.unmarshal_json_response(
317
+ errors.HTTPValidationErrorData, http_res
336
318
  )
337
- raise models.HTTPValidationError(data=response_data)
319
+ raise errors.HTTPValidationError(response_data, http_res)
338
320
  if utils.match_response(http_res, "4XX", "*"):
339
321
  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
- )
322
+ raise errors.APIError("API error occurred", http_res, http_res_text)
343
323
  if utils.match_response(http_res, "5XX", "*"):
344
324
  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
- )
325
+ raise errors.APIError("API error occurred", http_res, http_res_text)
348
326
 
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
- )
327
+ raise errors.APIError("Unexpected response received", http_res)
357
328
 
358
329
  async def update_async(
359
330
  self,
@@ -443,33 +414,22 @@ class Numbers(BaseSDK):
443
414
 
444
415
  response_data: Any = None
445
416
  if utils.match_response(http_res, "200", "application/json"):
446
- return utils.unmarshal_json(
447
- http_res.text, models.TwilioNumberUpdateResponse
417
+ return utils.unmarshal_json_response(
418
+ models.TwilioNumberUpdateResponse, http_res
448
419
  )
449
420
  if utils.match_response(http_res, "422", "application/json"):
450
- response_data = utils.unmarshal_json(
451
- http_res.text, models.HTTPValidationErrorData
421
+ response_data = utils.unmarshal_json_response(
422
+ errors.HTTPValidationErrorData, http_res
452
423
  )
453
- raise models.HTTPValidationError(data=response_data)
424
+ raise errors.HTTPValidationError(response_data, http_res)
454
425
  if utils.match_response(http_res, "4XX", "*"):
455
426
  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
- )
427
+ raise errors.APIError("API error occurred", http_res, http_res_text)
459
428
  if utils.match_response(http_res, "5XX", "*"):
460
429
  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
- )
430
+ raise errors.APIError("API error occurred", http_res, http_res_text)
464
431
 
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
- )
432
+ raise errors.APIError("Unexpected response received", http_res)
473
433
 
474
434
  def list(
475
435
  self,
@@ -545,31 +505,22 @@ class Numbers(BaseSDK):
545
505
 
546
506
  response_data: Any = None
547
507
  if utils.match_response(http_res, "200", "application/json"):
548
- return utils.unmarshal_json(http_res.text, models.TwilioListNumbersResponse)
508
+ return utils.unmarshal_json_response(
509
+ models.TwilioListNumbersResponse, http_res
510
+ )
549
511
  if utils.match_response(http_res, "422", "application/json"):
550
- response_data = utils.unmarshal_json(
551
- http_res.text, models.HTTPValidationErrorData
512
+ response_data = utils.unmarshal_json_response(
513
+ errors.HTTPValidationErrorData, http_res
552
514
  )
553
- raise models.HTTPValidationError(data=response_data)
515
+ raise errors.HTTPValidationError(response_data, http_res)
554
516
  if utils.match_response(http_res, "4XX", "*"):
555
517
  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
- )
518
+ raise errors.APIError("API error occurred", http_res, http_res_text)
559
519
  if utils.match_response(http_res, "5XX", "*"):
560
520
  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
- )
521
+ raise errors.APIError("API error occurred", http_res, http_res_text)
564
522
 
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
- )
523
+ raise errors.APIError("Unexpected response received", http_res)
573
524
 
574
525
  async def list_async(
575
526
  self,
@@ -645,28 +596,19 @@ class Numbers(BaseSDK):
645
596
 
646
597
  response_data: Any = None
647
598
  if utils.match_response(http_res, "200", "application/json"):
648
- return utils.unmarshal_json(http_res.text, models.TwilioListNumbersResponse)
599
+ return utils.unmarshal_json_response(
600
+ models.TwilioListNumbersResponse, http_res
601
+ )
649
602
  if utils.match_response(http_res, "422", "application/json"):
650
- response_data = utils.unmarshal_json(
651
- http_res.text, models.HTTPValidationErrorData
603
+ response_data = utils.unmarshal_json_response(
604
+ errors.HTTPValidationErrorData, http_res
652
605
  )
653
- raise models.HTTPValidationError(data=response_data)
606
+ raise errors.HTTPValidationError(response_data, http_res)
654
607
  if utils.match_response(http_res, "4XX", "*"):
655
608
  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
- )
609
+ raise errors.APIError("API error occurred", http_res, http_res_text)
659
610
  if utils.match_response(http_res, "5XX", "*"):
660
611
  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
- )
612
+ raise errors.APIError("API error occurred", http_res, http_res_text)
664
613
 
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
- )
614
+ raise errors.APIError("Unexpected response received", http_res)
@@ -1,7 +1,7 @@
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
@@ -77,26 +77,15 @@ class Organizations(BaseSDK):
77
77
  )
78
78
 
79
79
  if utils.match_response(http_res, "200", "application/json"):
80
- return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
80
+ return utils.unmarshal_json_response(models.OrganizationResponse, http_res)
81
81
  if utils.match_response(http_res, "4XX", "*"):
82
82
  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
- )
83
+ raise errors.APIError("API error occurred", http_res, http_res_text)
86
84
  if utils.match_response(http_res, "5XX", "*"):
87
85
  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
- )
86
+ raise errors.APIError("API error occurred", http_res, http_res_text)
91
87
 
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
- )
88
+ raise errors.APIError("Unexpected response received", http_res)
100
89
 
101
90
  async def organizations_get_async(
102
91
  self,
@@ -164,26 +153,15 @@ class Organizations(BaseSDK):
164
153
  )
165
154
 
166
155
  if utils.match_response(http_res, "200", "application/json"):
167
- return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
156
+ return utils.unmarshal_json_response(models.OrganizationResponse, http_res)
168
157
  if utils.match_response(http_res, "4XX", "*"):
169
158
  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
- )
159
+ raise errors.APIError("API error occurred", http_res, http_res_text)
173
160
  if utils.match_response(http_res, "5XX", "*"):
174
161
  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
- )
162
+ raise errors.APIError("API error occurred", http_res, http_res_text)
178
163
 
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
- )
164
+ raise errors.APIError("Unexpected response received", http_res)
187
165
 
188
166
  def update(
189
167
  self,
@@ -264,31 +242,20 @@ class Organizations(BaseSDK):
264
242
 
265
243
  response_data: Any = None
266
244
  if utils.match_response(http_res, "200", "application/json"):
267
- return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
245
+ return utils.unmarshal_json_response(models.OrganizationResponse, http_res)
268
246
  if utils.match_response(http_res, "422", "application/json"):
269
- response_data = utils.unmarshal_json(
270
- http_res.text, models.HTTPValidationErrorData
247
+ response_data = utils.unmarshal_json_response(
248
+ errors.HTTPValidationErrorData, http_res
271
249
  )
272
- raise models.HTTPValidationError(data=response_data)
250
+ raise errors.HTTPValidationError(response_data, http_res)
273
251
  if utils.match_response(http_res, "4XX", "*"):
274
252
  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
- )
253
+ raise errors.APIError("API error occurred", http_res, http_res_text)
278
254
  if utils.match_response(http_res, "5XX", "*"):
279
255
  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
- )
256
+ raise errors.APIError("API error occurred", http_res, http_res_text)
283
257
 
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
- )
258
+ raise errors.APIError("Unexpected response received", http_res)
292
259
 
293
260
  async def update_async(
294
261
  self,
@@ -369,31 +336,20 @@ class Organizations(BaseSDK):
369
336
 
370
337
  response_data: Any = None
371
338
  if utils.match_response(http_res, "200", "application/json"):
372
- return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
339
+ return utils.unmarshal_json_response(models.OrganizationResponse, http_res)
373
340
  if utils.match_response(http_res, "422", "application/json"):
374
- response_data = utils.unmarshal_json(
375
- http_res.text, models.HTTPValidationErrorData
341
+ response_data = utils.unmarshal_json_response(
342
+ errors.HTTPValidationErrorData, http_res
376
343
  )
377
- raise models.HTTPValidationError(data=response_data)
344
+ raise errors.HTTPValidationError(response_data, http_res)
378
345
  if utils.match_response(http_res, "4XX", "*"):
379
346
  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
- )
347
+ raise errors.APIError("API error occurred", http_res, http_res_text)
383
348
  if utils.match_response(http_res, "5XX", "*"):
384
349
  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
- )
350
+ raise errors.APIError("API error occurred", http_res, http_res_text)
388
351
 
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
- )
352
+ raise errors.APIError("Unexpected response received", http_res)
397
353
 
398
354
  def create(
399
355
  self,
@@ -474,31 +430,20 @@ class Organizations(BaseSDK):
474
430
 
475
431
  response_data: Any = None
476
432
  if utils.match_response(http_res, "200", "application/json"):
477
- return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
433
+ return utils.unmarshal_json_response(models.OrganizationResponse, http_res)
478
434
  if utils.match_response(http_res, "422", "application/json"):
479
- response_data = utils.unmarshal_json(
480
- http_res.text, models.HTTPValidationErrorData
435
+ response_data = utils.unmarshal_json_response(
436
+ errors.HTTPValidationErrorData, http_res
481
437
  )
482
- raise models.HTTPValidationError(data=response_data)
438
+ raise errors.HTTPValidationError(response_data, http_res)
483
439
  if utils.match_response(http_res, "4XX", "*"):
484
440
  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
- )
441
+ raise errors.APIError("API error occurred", http_res, http_res_text)
488
442
  if utils.match_response(http_res, "5XX", "*"):
489
443
  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
- )
444
+ raise errors.APIError("API error occurred", http_res, http_res_text)
493
445
 
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
- )
446
+ raise errors.APIError("Unexpected response received", http_res)
502
447
 
503
448
  async def create_async(
504
449
  self,
@@ -579,31 +524,20 @@ class Organizations(BaseSDK):
579
524
 
580
525
  response_data: Any = None
581
526
  if utils.match_response(http_res, "200", "application/json"):
582
- return utils.unmarshal_json(http_res.text, models.OrganizationResponse)
527
+ return utils.unmarshal_json_response(models.OrganizationResponse, http_res)
583
528
  if utils.match_response(http_res, "422", "application/json"):
584
- response_data = utils.unmarshal_json(
585
- http_res.text, models.HTTPValidationErrorData
529
+ response_data = utils.unmarshal_json_response(
530
+ errors.HTTPValidationErrorData, http_res
586
531
  )
587
- raise models.HTTPValidationError(data=response_data)
532
+ raise errors.HTTPValidationError(response_data, http_res)
588
533
  if utils.match_response(http_res, "4XX", "*"):
589
534
  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
- )
535
+ raise errors.APIError("API error occurred", http_res, http_res_text)
593
536
  if utils.match_response(http_res, "5XX", "*"):
594
537
  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
- )
538
+ raise errors.APIError("API error occurred", http_res, http_res_text)
598
539
 
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
- )
540
+ raise errors.APIError("Unexpected response received", http_res)
607
541
 
608
542
  def delete(
609
543
  self,
@@ -686,31 +620,20 @@ class Organizations(BaseSDK):
686
620
 
687
621
  response_data: Any = None
688
622
  if utils.match_response(http_res, "200", "application/json"):
689
- return utils.unmarshal_json(http_res.text, Any)
623
+ return utils.unmarshal_json_response(Any, http_res)
690
624
  if utils.match_response(http_res, "422", "application/json"):
691
- response_data = utils.unmarshal_json(
692
- http_res.text, models.HTTPValidationErrorData
625
+ response_data = utils.unmarshal_json_response(
626
+ errors.HTTPValidationErrorData, http_res
693
627
  )
694
- raise models.HTTPValidationError(data=response_data)
628
+ raise errors.HTTPValidationError(response_data, http_res)
695
629
  if utils.match_response(http_res, "4XX", "*"):
696
630
  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
- )
631
+ raise errors.APIError("API error occurred", http_res, http_res_text)
700
632
  if utils.match_response(http_res, "5XX", "*"):
701
633
  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
- )
634
+ raise errors.APIError("API error occurred", http_res, http_res_text)
705
635
 
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
- )
636
+ raise errors.APIError("Unexpected response received", http_res)
714
637
 
715
638
  async def delete_async(
716
639
  self,
@@ -793,28 +716,17 @@ class Organizations(BaseSDK):
793
716
 
794
717
  response_data: Any = None
795
718
  if utils.match_response(http_res, "200", "application/json"):
796
- return utils.unmarshal_json(http_res.text, Any)
719
+ return utils.unmarshal_json_response(Any, http_res)
797
720
  if utils.match_response(http_res, "422", "application/json"):
798
- response_data = utils.unmarshal_json(
799
- http_res.text, models.HTTPValidationErrorData
721
+ response_data = utils.unmarshal_json_response(
722
+ errors.HTTPValidationErrorData, http_res
800
723
  )
801
- raise models.HTTPValidationError(data=response_data)
724
+ raise errors.HTTPValidationError(response_data, http_res)
802
725
  if utils.match_response(http_res, "4XX", "*"):
803
726
  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
- )
727
+ raise errors.APIError("API error occurred", http_res, http_res_text)
807
728
  if utils.match_response(http_res, "5XX", "*"):
808
729
  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
- )
730
+ raise errors.APIError("API error occurred", http_res, http_res_text)
812
731
 
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
- )
732
+ raise errors.APIError("Unexpected response received", http_res)
@@ -1,7 +1,7 @@
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
@@ -77,28 +77,17 @@ class Permissions(BaseSDK):
77
77
  )
78
78
 
79
79
  if utils.match_response(http_res, "200", "application/json"):
80
- return utils.unmarshal_json(
81
- http_res.text, List[models.PermissionGroupResponse]
80
+ return utils.unmarshal_json_response(
81
+ List[models.PermissionGroupResponse], http_res
82
82
  )
83
83
  if utils.match_response(http_res, "4XX", "*"):
84
84
  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
- )
85
+ raise errors.APIError("API error occurred", http_res, http_res_text)
88
86
  if utils.match_response(http_res, "5XX", "*"):
89
87
  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
- )
88
+ raise errors.APIError("API error occurred", http_res, http_res_text)
93
89
 
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
- )
90
+ raise errors.APIError("Unexpected response received", http_res)
102
91
 
103
92
  async def list_async(
104
93
  self,
@@ -166,25 +155,14 @@ class Permissions(BaseSDK):
166
155
  )
167
156
 
168
157
  if utils.match_response(http_res, "200", "application/json"):
169
- return utils.unmarshal_json(
170
- http_res.text, List[models.PermissionGroupResponse]
158
+ return utils.unmarshal_json_response(
159
+ List[models.PermissionGroupResponse], http_res
171
160
  )
172
161
  if utils.match_response(http_res, "4XX", "*"):
173
162
  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
- )
163
+ raise errors.APIError("API error occurred", http_res, http_res_text)
177
164
  if utils.match_response(http_res, "5XX", "*"):
178
165
  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
- )
166
+ raise errors.APIError("API error occurred", http_res, http_res_text)
182
167
 
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
- )
168
+ raise errors.APIError("Unexpected response received", http_res)