syllable-sdk 0.35.31__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.31.dist-info → syllable_sdk-0.35.33.dist-info}/METADATA +58 -45
  48. {syllable_sdk-0.35.31.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.31.dist-info → syllable_sdk-0.35.33.dist-info}/WHEEL +0 -0
@@ -2,7 +2,7 @@
2
2
 
3
3
  from .basesdk import BaseSDK
4
4
  import httpx
5
- from syllable_sdk import models, utils
5
+ from syllable_sdk import errors, models, utils
6
6
  from syllable_sdk._hooks import HookContext
7
7
  from syllable_sdk.types import BaseModel, OptionalNullable, UNSET
8
8
  from syllable_sdk.utils import get_security_from_env
@@ -110,33 +110,22 @@ class LanguageGroups(BaseSDK):
110
110
 
111
111
  response_data: Any = None
112
112
  if utils.match_response(http_res, "200", "application/json"):
113
- return utils.unmarshal_json(
114
- http_res.text, models.ListResponseLanguageGroupResponse
113
+ return utils.unmarshal_json_response(
114
+ models.ListResponseLanguageGroupResponse, http_res
115
115
  )
116
116
  if utils.match_response(http_res, "422", "application/json"):
117
- response_data = utils.unmarshal_json(
118
- http_res.text, models.HTTPValidationErrorData
117
+ response_data = utils.unmarshal_json_response(
118
+ errors.HTTPValidationErrorData, http_res
119
119
  )
120
- raise models.HTTPValidationError(data=response_data)
120
+ raise errors.HTTPValidationError(response_data, http_res)
121
121
  if utils.match_response(http_res, "4XX", "*"):
122
122
  http_res_text = utils.stream_to_text(http_res)
123
- raise models.APIError(
124
- "API error occurred", http_res.status_code, http_res_text, http_res
125
- )
123
+ raise errors.APIError("API error occurred", http_res, http_res_text)
126
124
  if utils.match_response(http_res, "5XX", "*"):
127
125
  http_res_text = utils.stream_to_text(http_res)
128
- raise models.APIError(
129
- "API error occurred", http_res.status_code, http_res_text, http_res
130
- )
126
+ raise errors.APIError("API error occurred", http_res, http_res_text)
131
127
 
132
- content_type = http_res.headers.get("Content-Type")
133
- http_res_text = utils.stream_to_text(http_res)
134
- raise models.APIError(
135
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
136
- http_res.status_code,
137
- http_res_text,
138
- http_res,
139
- )
128
+ raise errors.APIError("Unexpected response received", http_res)
140
129
 
141
130
  async def list_async(
142
131
  self,
@@ -236,33 +225,22 @@ class LanguageGroups(BaseSDK):
236
225
 
237
226
  response_data: Any = None
238
227
  if utils.match_response(http_res, "200", "application/json"):
239
- return utils.unmarshal_json(
240
- http_res.text, models.ListResponseLanguageGroupResponse
228
+ return utils.unmarshal_json_response(
229
+ models.ListResponseLanguageGroupResponse, http_res
241
230
  )
242
231
  if utils.match_response(http_res, "422", "application/json"):
243
- response_data = utils.unmarshal_json(
244
- http_res.text, models.HTTPValidationErrorData
232
+ response_data = utils.unmarshal_json_response(
233
+ errors.HTTPValidationErrorData, http_res
245
234
  )
246
- raise models.HTTPValidationError(data=response_data)
235
+ raise errors.HTTPValidationError(response_data, http_res)
247
236
  if utils.match_response(http_res, "4XX", "*"):
248
237
  http_res_text = await utils.stream_to_text_async(http_res)
249
- raise models.APIError(
250
- "API error occurred", http_res.status_code, http_res_text, http_res
251
- )
238
+ raise errors.APIError("API error occurred", http_res, http_res_text)
252
239
  if utils.match_response(http_res, "5XX", "*"):
253
240
  http_res_text = await utils.stream_to_text_async(http_res)
254
- raise models.APIError(
255
- "API error occurred", http_res.status_code, http_res_text, http_res
256
- )
241
+ raise errors.APIError("API error occurred", http_res, http_res_text)
257
242
 
258
- content_type = http_res.headers.get("Content-Type")
259
- http_res_text = await utils.stream_to_text_async(http_res)
260
- raise models.APIError(
261
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
262
- http_res.status_code,
263
- http_res_text,
264
- http_res,
265
- )
243
+ raise errors.APIError("Unexpected response received", http_res)
266
244
 
267
245
  def create(
268
246
  self,
@@ -344,31 +322,20 @@ class LanguageGroups(BaseSDK):
344
322
 
345
323
  response_data: Any = None
346
324
  if utils.match_response(http_res, "200", "application/json"):
347
- return utils.unmarshal_json(http_res.text, models.LanguageGroupResponse)
325
+ return utils.unmarshal_json_response(models.LanguageGroupResponse, http_res)
348
326
  if utils.match_response(http_res, "422", "application/json"):
349
- response_data = utils.unmarshal_json(
350
- http_res.text, models.HTTPValidationErrorData
327
+ response_data = utils.unmarshal_json_response(
328
+ errors.HTTPValidationErrorData, http_res
351
329
  )
352
- raise models.HTTPValidationError(data=response_data)
330
+ raise errors.HTTPValidationError(response_data, http_res)
353
331
  if utils.match_response(http_res, "4XX", "*"):
354
332
  http_res_text = utils.stream_to_text(http_res)
355
- raise models.APIError(
356
- "API error occurred", http_res.status_code, http_res_text, http_res
357
- )
333
+ raise errors.APIError("API error occurred", http_res, http_res_text)
358
334
  if utils.match_response(http_res, "5XX", "*"):
359
335
  http_res_text = utils.stream_to_text(http_res)
360
- raise models.APIError(
361
- "API error occurred", http_res.status_code, http_res_text, http_res
362
- )
336
+ raise errors.APIError("API error occurred", http_res, http_res_text)
363
337
 
364
- content_type = http_res.headers.get("Content-Type")
365
- http_res_text = utils.stream_to_text(http_res)
366
- raise models.APIError(
367
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
368
- http_res.status_code,
369
- http_res_text,
370
- http_res,
371
- )
338
+ raise errors.APIError("Unexpected response received", http_res)
372
339
 
373
340
  async def create_async(
374
341
  self,
@@ -450,31 +417,20 @@ class LanguageGroups(BaseSDK):
450
417
 
451
418
  response_data: Any = None
452
419
  if utils.match_response(http_res, "200", "application/json"):
453
- return utils.unmarshal_json(http_res.text, models.LanguageGroupResponse)
420
+ return utils.unmarshal_json_response(models.LanguageGroupResponse, http_res)
454
421
  if utils.match_response(http_res, "422", "application/json"):
455
- response_data = utils.unmarshal_json(
456
- http_res.text, models.HTTPValidationErrorData
422
+ response_data = utils.unmarshal_json_response(
423
+ errors.HTTPValidationErrorData, http_res
457
424
  )
458
- raise models.HTTPValidationError(data=response_data)
425
+ raise errors.HTTPValidationError(response_data, http_res)
459
426
  if utils.match_response(http_res, "4XX", "*"):
460
427
  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
- )
428
+ raise errors.APIError("API error occurred", http_res, http_res_text)
464
429
  if utils.match_response(http_res, "5XX", "*"):
465
430
  http_res_text = await utils.stream_to_text_async(http_res)
466
- raise models.APIError(
467
- "API error occurred", http_res.status_code, http_res_text, http_res
468
- )
431
+ raise errors.APIError("API error occurred", http_res, http_res_text)
469
432
 
470
- content_type = http_res.headers.get("Content-Type")
471
- http_res_text = await utils.stream_to_text_async(http_res)
472
- raise models.APIError(
473
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
474
- http_res.status_code,
475
- http_res_text,
476
- http_res,
477
- )
433
+ raise errors.APIError("Unexpected response received", http_res)
478
434
 
479
435
  def update(
480
436
  self,
@@ -556,31 +512,20 @@ class LanguageGroups(BaseSDK):
556
512
 
557
513
  response_data: Any = None
558
514
  if utils.match_response(http_res, "200", "application/json"):
559
- return utils.unmarshal_json(http_res.text, models.LanguageGroupResponse)
515
+ return utils.unmarshal_json_response(models.LanguageGroupResponse, http_res)
560
516
  if utils.match_response(http_res, "422", "application/json"):
561
- response_data = utils.unmarshal_json(
562
- http_res.text, models.HTTPValidationErrorData
517
+ response_data = utils.unmarshal_json_response(
518
+ errors.HTTPValidationErrorData, http_res
563
519
  )
564
- raise models.HTTPValidationError(data=response_data)
520
+ raise errors.HTTPValidationError(response_data, http_res)
565
521
  if utils.match_response(http_res, "4XX", "*"):
566
522
  http_res_text = utils.stream_to_text(http_res)
567
- raise models.APIError(
568
- "API error occurred", http_res.status_code, http_res_text, http_res
569
- )
523
+ raise errors.APIError("API error occurred", http_res, http_res_text)
570
524
  if utils.match_response(http_res, "5XX", "*"):
571
525
  http_res_text = utils.stream_to_text(http_res)
572
- raise models.APIError(
573
- "API error occurred", http_res.status_code, http_res_text, http_res
574
- )
526
+ raise errors.APIError("API error occurred", http_res, http_res_text)
575
527
 
576
- content_type = http_res.headers.get("Content-Type")
577
- http_res_text = utils.stream_to_text(http_res)
578
- raise models.APIError(
579
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
580
- http_res.status_code,
581
- http_res_text,
582
- http_res,
583
- )
528
+ raise errors.APIError("Unexpected response received", http_res)
584
529
 
585
530
  async def update_async(
586
531
  self,
@@ -662,31 +607,20 @@ class LanguageGroups(BaseSDK):
662
607
 
663
608
  response_data: Any = None
664
609
  if utils.match_response(http_res, "200", "application/json"):
665
- return utils.unmarshal_json(http_res.text, models.LanguageGroupResponse)
610
+ return utils.unmarshal_json_response(models.LanguageGroupResponse, http_res)
666
611
  if utils.match_response(http_res, "422", "application/json"):
667
- response_data = utils.unmarshal_json(
668
- http_res.text, models.HTTPValidationErrorData
612
+ response_data = utils.unmarshal_json_response(
613
+ errors.HTTPValidationErrorData, http_res
669
614
  )
670
- raise models.HTTPValidationError(data=response_data)
615
+ raise errors.HTTPValidationError(response_data, http_res)
671
616
  if utils.match_response(http_res, "4XX", "*"):
672
617
  http_res_text = await utils.stream_to_text_async(http_res)
673
- raise models.APIError(
674
- "API error occurred", http_res.status_code, http_res_text, http_res
675
- )
618
+ raise errors.APIError("API error occurred", http_res, http_res_text)
676
619
  if utils.match_response(http_res, "5XX", "*"):
677
620
  http_res_text = await utils.stream_to_text_async(http_res)
678
- raise models.APIError(
679
- "API error occurred", http_res.status_code, http_res_text, http_res
680
- )
621
+ raise errors.APIError("API error occurred", http_res, http_res_text)
681
622
 
682
- content_type = http_res.headers.get("Content-Type")
683
- http_res_text = await utils.stream_to_text_async(http_res)
684
- raise models.APIError(
685
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
686
- http_res.status_code,
687
- http_res_text,
688
- http_res,
689
- )
623
+ raise errors.APIError("Unexpected response received", http_res)
690
624
 
691
625
  def get_by_id(
692
626
  self,
@@ -762,31 +696,20 @@ class LanguageGroups(BaseSDK):
762
696
 
763
697
  response_data: Any = None
764
698
  if utils.match_response(http_res, "200", "application/json"):
765
- return utils.unmarshal_json(http_res.text, models.LanguageGroupResponse)
699
+ return utils.unmarshal_json_response(models.LanguageGroupResponse, http_res)
766
700
  if utils.match_response(http_res, "422", "application/json"):
767
- response_data = utils.unmarshal_json(
768
- http_res.text, models.HTTPValidationErrorData
701
+ response_data = utils.unmarshal_json_response(
702
+ errors.HTTPValidationErrorData, http_res
769
703
  )
770
- raise models.HTTPValidationError(data=response_data)
704
+ raise errors.HTTPValidationError(response_data, http_res)
771
705
  if utils.match_response(http_res, "4XX", "*"):
772
706
  http_res_text = utils.stream_to_text(http_res)
773
- raise models.APIError(
774
- "API error occurred", http_res.status_code, http_res_text, http_res
775
- )
707
+ raise errors.APIError("API error occurred", http_res, http_res_text)
776
708
  if utils.match_response(http_res, "5XX", "*"):
777
709
  http_res_text = utils.stream_to_text(http_res)
778
- raise models.APIError(
779
- "API error occurred", http_res.status_code, http_res_text, http_res
780
- )
710
+ raise errors.APIError("API error occurred", http_res, http_res_text)
781
711
 
782
- content_type = http_res.headers.get("Content-Type")
783
- http_res_text = utils.stream_to_text(http_res)
784
- raise models.APIError(
785
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
786
- http_res.status_code,
787
- http_res_text,
788
- http_res,
789
- )
712
+ raise errors.APIError("Unexpected response received", http_res)
790
713
 
791
714
  async def get_by_id_async(
792
715
  self,
@@ -862,31 +785,20 @@ class LanguageGroups(BaseSDK):
862
785
 
863
786
  response_data: Any = None
864
787
  if utils.match_response(http_res, "200", "application/json"):
865
- return utils.unmarshal_json(http_res.text, models.LanguageGroupResponse)
788
+ return utils.unmarshal_json_response(models.LanguageGroupResponse, http_res)
866
789
  if utils.match_response(http_res, "422", "application/json"):
867
- response_data = utils.unmarshal_json(
868
- http_res.text, models.HTTPValidationErrorData
790
+ response_data = utils.unmarshal_json_response(
791
+ errors.HTTPValidationErrorData, http_res
869
792
  )
870
- raise models.HTTPValidationError(data=response_data)
793
+ raise errors.HTTPValidationError(response_data, http_res)
871
794
  if utils.match_response(http_res, "4XX", "*"):
872
795
  http_res_text = await utils.stream_to_text_async(http_res)
873
- raise models.APIError(
874
- "API error occurred", http_res.status_code, http_res_text, http_res
875
- )
796
+ raise errors.APIError("API error occurred", http_res, http_res_text)
876
797
  if utils.match_response(http_res, "5XX", "*"):
877
798
  http_res_text = await utils.stream_to_text_async(http_res)
878
- raise models.APIError(
879
- "API error occurred", http_res.status_code, http_res_text, http_res
880
- )
799
+ raise errors.APIError("API error occurred", http_res, http_res_text)
881
800
 
882
- content_type = http_res.headers.get("Content-Type")
883
- http_res_text = await utils.stream_to_text_async(http_res)
884
- raise models.APIError(
885
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
886
- http_res.status_code,
887
- http_res_text,
888
- http_res,
889
- )
801
+ raise errors.APIError("Unexpected response received", http_res)
890
802
 
891
803
  def delete(
892
804
  self,
@@ -965,31 +877,20 @@ class LanguageGroups(BaseSDK):
965
877
 
966
878
  response_data: Any = None
967
879
  if utils.match_response(http_res, "200", "application/json"):
968
- return utils.unmarshal_json(http_res.text, Any)
880
+ return utils.unmarshal_json_response(Any, http_res)
969
881
  if utils.match_response(http_res, "422", "application/json"):
970
- response_data = utils.unmarshal_json(
971
- http_res.text, models.HTTPValidationErrorData
882
+ response_data = utils.unmarshal_json_response(
883
+ errors.HTTPValidationErrorData, http_res
972
884
  )
973
- raise models.HTTPValidationError(data=response_data)
885
+ raise errors.HTTPValidationError(response_data, http_res)
974
886
  if utils.match_response(http_res, "4XX", "*"):
975
887
  http_res_text = utils.stream_to_text(http_res)
976
- raise models.APIError(
977
- "API error occurred", http_res.status_code, http_res_text, http_res
978
- )
888
+ raise errors.APIError("API error occurred", http_res, http_res_text)
979
889
  if utils.match_response(http_res, "5XX", "*"):
980
890
  http_res_text = utils.stream_to_text(http_res)
981
- raise models.APIError(
982
- "API error occurred", http_res.status_code, http_res_text, http_res
983
- )
891
+ raise errors.APIError("API error occurred", http_res, http_res_text)
984
892
 
985
- content_type = http_res.headers.get("Content-Type")
986
- http_res_text = utils.stream_to_text(http_res)
987
- raise models.APIError(
988
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
989
- http_res.status_code,
990
- http_res_text,
991
- http_res,
992
- )
893
+ raise errors.APIError("Unexpected response received", http_res)
993
894
 
994
895
  async def delete_async(
995
896
  self,
@@ -1068,31 +969,20 @@ class LanguageGroups(BaseSDK):
1068
969
 
1069
970
  response_data: Any = None
1070
971
  if utils.match_response(http_res, "200", "application/json"):
1071
- return utils.unmarshal_json(http_res.text, Any)
972
+ return utils.unmarshal_json_response(Any, http_res)
1072
973
  if utils.match_response(http_res, "422", "application/json"):
1073
- response_data = utils.unmarshal_json(
1074
- http_res.text, models.HTTPValidationErrorData
974
+ response_data = utils.unmarshal_json_response(
975
+ errors.HTTPValidationErrorData, http_res
1075
976
  )
1076
- raise models.HTTPValidationError(data=response_data)
977
+ raise errors.HTTPValidationError(response_data, http_res)
1077
978
  if utils.match_response(http_res, "4XX", "*"):
1078
979
  http_res_text = await utils.stream_to_text_async(http_res)
1079
- raise models.APIError(
1080
- "API error occurred", http_res.status_code, http_res_text, http_res
1081
- )
980
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1082
981
  if utils.match_response(http_res, "5XX", "*"):
1083
982
  http_res_text = await utils.stream_to_text_async(http_res)
1084
- raise models.APIError(
1085
- "API error occurred", http_res.status_code, http_res_text, http_res
1086
- )
983
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1087
984
 
1088
- content_type = http_res.headers.get("Content-Type")
1089
- http_res_text = await utils.stream_to_text_async(http_res)
1090
- raise models.APIError(
1091
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1092
- http_res.status_code,
1093
- http_res_text,
1094
- http_res,
1095
- )
985
+ raise errors.APIError("Unexpected response received", http_res)
1096
986
 
1097
987
  def language_groups_create_voice_sample(
1098
988
  self,
@@ -1177,29 +1067,19 @@ class LanguageGroups(BaseSDK):
1177
1067
  return http_res
1178
1068
  if utils.match_response(http_res, "422", "application/json"):
1179
1069
  http_res_text = utils.stream_to_text(http_res)
1180
- response_data = utils.unmarshal_json(
1181
- http_res_text, models.HTTPValidationErrorData
1070
+ response_data = utils.unmarshal_json_response(
1071
+ errors.HTTPValidationErrorData, http_res, http_res_text
1182
1072
  )
1183
- raise models.HTTPValidationError(data=response_data)
1073
+ raise errors.HTTPValidationError(response_data, http_res, http_res_text)
1184
1074
  if utils.match_response(http_res, "4XX", "*"):
1185
1075
  http_res_text = utils.stream_to_text(http_res)
1186
- raise models.APIError(
1187
- "API error occurred", http_res.status_code, http_res_text, http_res
1188
- )
1076
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1189
1077
  if utils.match_response(http_res, "5XX", "*"):
1190
1078
  http_res_text = utils.stream_to_text(http_res)
1191
- raise models.APIError(
1192
- "API error occurred", http_res.status_code, http_res_text, http_res
1193
- )
1079
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1194
1080
 
1195
- content_type = http_res.headers.get("Content-Type")
1196
1081
  http_res_text = utils.stream_to_text(http_res)
1197
- raise models.APIError(
1198
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1199
- http_res.status_code,
1200
- http_res_text,
1201
- http_res,
1202
- )
1082
+ raise errors.APIError("Unexpected response received", http_res, http_res_text)
1203
1083
 
1204
1084
  async def language_groups_create_voice_sample_async(
1205
1085
  self,
@@ -1284,26 +1164,16 @@ class LanguageGroups(BaseSDK):
1284
1164
  return http_res
1285
1165
  if utils.match_response(http_res, "422", "application/json"):
1286
1166
  http_res_text = await utils.stream_to_text_async(http_res)
1287
- response_data = utils.unmarshal_json(
1288
- http_res_text, models.HTTPValidationErrorData
1167
+ response_data = utils.unmarshal_json_response(
1168
+ errors.HTTPValidationErrorData, http_res, http_res_text
1289
1169
  )
1290
- raise models.HTTPValidationError(data=response_data)
1170
+ raise errors.HTTPValidationError(response_data, http_res, http_res_text)
1291
1171
  if utils.match_response(http_res, "4XX", "*"):
1292
1172
  http_res_text = await utils.stream_to_text_async(http_res)
1293
- raise models.APIError(
1294
- "API error occurred", http_res.status_code, http_res_text, http_res
1295
- )
1173
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1296
1174
  if utils.match_response(http_res, "5XX", "*"):
1297
1175
  http_res_text = await utils.stream_to_text_async(http_res)
1298
- raise models.APIError(
1299
- "API error occurred", http_res.status_code, http_res_text, http_res
1300
- )
1176
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1301
1177
 
1302
- content_type = http_res.headers.get("Content-Type")
1303
1178
  http_res_text = await utils.stream_to_text_async(http_res)
1304
- raise models.APIError(
1305
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1306
- http_res.status_code,
1307
- http_res_text,
1308
- http_res,
1309
- )
1179
+ raise errors.APIError("Unexpected response received", http_res, http_res_text)
syllable_sdk/latency.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
@@ -81,31 +81,22 @@ class Latency(BaseSDK):
81
81
 
82
82
  response_data: Any = None
83
83
  if utils.match_response(http_res, "200", "application/json"):
84
- return utils.unmarshal_json(http_res.text, models.InspectLatencyResponse)
84
+ return utils.unmarshal_json_response(
85
+ models.InspectLatencyResponse, http_res
86
+ )
85
87
  if utils.match_response(http_res, "422", "application/json"):
86
- response_data = utils.unmarshal_json(
87
- http_res.text, models.HTTPValidationErrorData
88
+ response_data = utils.unmarshal_json_response(
89
+ errors.HTTPValidationErrorData, http_res
88
90
  )
89
- raise models.HTTPValidationError(data=response_data)
91
+ raise errors.HTTPValidationError(response_data, http_res)
90
92
  if utils.match_response(http_res, "4XX", "*"):
91
93
  http_res_text = utils.stream_to_text(http_res)
92
- raise models.APIError(
93
- "API error occurred", http_res.status_code, http_res_text, http_res
94
- )
94
+ raise errors.APIError("API error occurred", http_res, http_res_text)
95
95
  if utils.match_response(http_res, "5XX", "*"):
96
96
  http_res_text = utils.stream_to_text(http_res)
97
- raise models.APIError(
98
- "API error occurred", http_res.status_code, http_res_text, http_res
99
- )
97
+ raise errors.APIError("API error occurred", http_res, http_res_text)
100
98
 
101
- content_type = http_res.headers.get("Content-Type")
102
- http_res_text = utils.stream_to_text(http_res)
103
- raise models.APIError(
104
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
105
- http_res.status_code,
106
- http_res_text,
107
- http_res,
108
- )
99
+ raise errors.APIError("Unexpected response received", http_res)
109
100
 
110
101
  async def get_by_id_async(
111
102
  self,
@@ -179,28 +170,19 @@ class Latency(BaseSDK):
179
170
 
180
171
  response_data: Any = None
181
172
  if utils.match_response(http_res, "200", "application/json"):
182
- return utils.unmarshal_json(http_res.text, models.InspectLatencyResponse)
173
+ return utils.unmarshal_json_response(
174
+ models.InspectLatencyResponse, http_res
175
+ )
183
176
  if utils.match_response(http_res, "422", "application/json"):
184
- response_data = utils.unmarshal_json(
185
- http_res.text, models.HTTPValidationErrorData
177
+ response_data = utils.unmarshal_json_response(
178
+ errors.HTTPValidationErrorData, http_res
186
179
  )
187
- raise models.HTTPValidationError(data=response_data)
180
+ raise errors.HTTPValidationError(response_data, http_res)
188
181
  if utils.match_response(http_res, "4XX", "*"):
189
182
  http_res_text = await utils.stream_to_text_async(http_res)
190
- raise models.APIError(
191
- "API error occurred", http_res.status_code, http_res_text, http_res
192
- )
183
+ raise errors.APIError("API error occurred", http_res, http_res_text)
193
184
  if utils.match_response(http_res, "5XX", "*"):
194
185
  http_res_text = await utils.stream_to_text_async(http_res)
195
- raise models.APIError(
196
- "API error occurred", http_res.status_code, http_res_text, http_res
197
- )
186
+ raise errors.APIError("API error occurred", http_res, http_res_text)
198
187
 
199
- content_type = http_res.headers.get("Content-Type")
200
- http_res_text = await utils.stream_to_text_async(http_res)
201
- raise models.APIError(
202
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
203
- http_res.status_code,
204
- http_res_text,
205
- http_res,
206
- )
188
+ raise errors.APIError("Unexpected response received", http_res)
@@ -25,7 +25,6 @@ if TYPE_CHECKING:
25
25
  from .agentvoicemodel import AgentVoiceModel
26
26
  from .agentvoicevarname import AgentVoiceVarName
27
27
  from .agentwaitsound import AgentWaitSound
28
- from .apierror import APIError
29
28
  from .available_targetsop import (
30
29
  AvailableTargetsRequest,
31
30
  AvailableTargetsRequestTypedDict,
@@ -238,7 +237,6 @@ if TYPE_CHECKING:
238
237
  GetSessionToolCallResultByIDRequest,
239
238
  GetSessionToolCallResultByIDRequestTypedDict,
240
239
  )
241
- from .httpvalidationerror import HTTPValidationError, HTTPValidationErrorData
242
240
  from .incident_deleteop import IncidentDeleteRequest, IncidentDeleteRequestTypedDict
243
241
  from .incident_get_by_idop import (
244
242
  IncidentGetByIDRequest,
@@ -802,7 +800,6 @@ ChannelTargetResponse.model_rebuild()
802
800
 
803
801
 
804
802
  __all__ = [
805
- "APIError",
806
803
  "Action",
807
804
  "AgentCreate",
808
805
  "AgentCreateTypedDict",
@@ -976,8 +973,6 @@ __all__ = [
976
973
  "GetSessionDataBySidRequestTypedDict",
977
974
  "GetSessionToolCallResultByIDRequest",
978
975
  "GetSessionToolCallResultByIDRequestTypedDict",
979
- "HTTPValidationError",
980
- "HTTPValidationErrorData",
981
976
  "IncidentCreateRequest",
982
977
  "IncidentCreateRequestTypedDict",
983
978
  "IncidentDeleteRequest",
@@ -1401,7 +1396,6 @@ _dynamic_imports: dict[str, str] = {
1401
1396
  "AgentVoiceModel": ".agentvoicemodel",
1402
1397
  "AgentVoiceVarName": ".agentvoicevarname",
1403
1398
  "AgentWaitSound": ".agentwaitsound",
1404
- "APIError": ".apierror",
1405
1399
  "AvailableTargetsRequest": ".available_targetsop",
1406
1400
  "AvailableTargetsRequestTypedDict": ".available_targetsop",
1407
1401
  "AvailableTarget": ".availabletarget",
@@ -1543,8 +1537,6 @@ _dynamic_imports: dict[str, str] = {
1543
1537
  "GetSessionDataBySidRequestTypedDict": ".get_session_data_by_sidop",
1544
1538
  "GetSessionToolCallResultByIDRequest": ".get_session_tool_call_result_by_idop",
1545
1539
  "GetSessionToolCallResultByIDRequestTypedDict": ".get_session_tool_call_result_by_idop",
1546
- "HTTPValidationError": ".httpvalidationerror",
1547
- "HTTPValidationErrorData": ".httpvalidationerror",
1548
1540
  "IncidentDeleteRequest": ".incident_deleteop",
1549
1541
  "IncidentDeleteRequestTypedDict": ".incident_deleteop",
1550
1542
  "IncidentGetByIDRequest": ".incident_get_by_idop",