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
@@ -2,10 +2,11 @@
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
9
+ from syllable_sdk.utils.unmarshal_json_response import unmarshal_json_response
9
10
  from typing import Any, List, Mapping, Optional, Union, cast
10
11
 
11
12
 
@@ -110,33 +111,22 @@ class LanguageGroups(BaseSDK):
110
111
 
111
112
  response_data: Any = None
112
113
  if utils.match_response(http_res, "200", "application/json"):
113
- return utils.unmarshal_json(
114
- http_res.text, models.ListResponseLanguageGroupResponse
114
+ return unmarshal_json_response(
115
+ models.ListResponseLanguageGroupResponse, http_res
115
116
  )
116
117
  if utils.match_response(http_res, "422", "application/json"):
117
- response_data = utils.unmarshal_json(
118
- http_res.text, models.HTTPValidationErrorData
118
+ response_data = unmarshal_json_response(
119
+ errors.HTTPValidationErrorData, http_res
119
120
  )
120
- raise models.HTTPValidationError(data=response_data)
121
+ raise errors.HTTPValidationError(response_data, http_res)
121
122
  if utils.match_response(http_res, "4XX", "*"):
122
123
  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
- )
124
+ raise errors.APIError("API error occurred", http_res, http_res_text)
126
125
  if utils.match_response(http_res, "5XX", "*"):
127
126
  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
- )
127
+ raise errors.APIError("API error occurred", http_res, http_res_text)
131
128
 
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
- )
129
+ raise errors.APIError("Unexpected response received", http_res)
140
130
 
141
131
  async def list_async(
142
132
  self,
@@ -236,33 +226,22 @@ class LanguageGroups(BaseSDK):
236
226
 
237
227
  response_data: Any = None
238
228
  if utils.match_response(http_res, "200", "application/json"):
239
- return utils.unmarshal_json(
240
- http_res.text, models.ListResponseLanguageGroupResponse
229
+ return unmarshal_json_response(
230
+ models.ListResponseLanguageGroupResponse, http_res
241
231
  )
242
232
  if utils.match_response(http_res, "422", "application/json"):
243
- response_data = utils.unmarshal_json(
244
- http_res.text, models.HTTPValidationErrorData
233
+ response_data = unmarshal_json_response(
234
+ errors.HTTPValidationErrorData, http_res
245
235
  )
246
- raise models.HTTPValidationError(data=response_data)
236
+ raise errors.HTTPValidationError(response_data, http_res)
247
237
  if utils.match_response(http_res, "4XX", "*"):
248
238
  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
- )
239
+ raise errors.APIError("API error occurred", http_res, http_res_text)
252
240
  if utils.match_response(http_res, "5XX", "*"):
253
241
  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
- )
242
+ raise errors.APIError("API error occurred", http_res, http_res_text)
257
243
 
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
- )
244
+ raise errors.APIError("Unexpected response received", http_res)
266
245
 
267
246
  def create(
268
247
  self,
@@ -344,31 +323,20 @@ class LanguageGroups(BaseSDK):
344
323
 
345
324
  response_data: Any = None
346
325
  if utils.match_response(http_res, "200", "application/json"):
347
- return utils.unmarshal_json(http_res.text, models.LanguageGroupResponse)
326
+ return unmarshal_json_response(models.LanguageGroupResponse, http_res)
348
327
  if utils.match_response(http_res, "422", "application/json"):
349
- response_data = utils.unmarshal_json(
350
- http_res.text, models.HTTPValidationErrorData
328
+ response_data = unmarshal_json_response(
329
+ errors.HTTPValidationErrorData, http_res
351
330
  )
352
- raise models.HTTPValidationError(data=response_data)
331
+ raise errors.HTTPValidationError(response_data, http_res)
353
332
  if utils.match_response(http_res, "4XX", "*"):
354
333
  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
- )
334
+ raise errors.APIError("API error occurred", http_res, http_res_text)
358
335
  if utils.match_response(http_res, "5XX", "*"):
359
336
  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
- )
337
+ raise errors.APIError("API error occurred", http_res, http_res_text)
363
338
 
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
- )
339
+ raise errors.APIError("Unexpected response received", http_res)
372
340
 
373
341
  async def create_async(
374
342
  self,
@@ -450,31 +418,20 @@ class LanguageGroups(BaseSDK):
450
418
 
451
419
  response_data: Any = None
452
420
  if utils.match_response(http_res, "200", "application/json"):
453
- return utils.unmarshal_json(http_res.text, models.LanguageGroupResponse)
421
+ return unmarshal_json_response(models.LanguageGroupResponse, http_res)
454
422
  if utils.match_response(http_res, "422", "application/json"):
455
- response_data = utils.unmarshal_json(
456
- http_res.text, models.HTTPValidationErrorData
423
+ response_data = unmarshal_json_response(
424
+ errors.HTTPValidationErrorData, http_res
457
425
  )
458
- raise models.HTTPValidationError(data=response_data)
426
+ raise errors.HTTPValidationError(response_data, http_res)
459
427
  if utils.match_response(http_res, "4XX", "*"):
460
428
  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
- )
429
+ raise errors.APIError("API error occurred", http_res, http_res_text)
464
430
  if utils.match_response(http_res, "5XX", "*"):
465
431
  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
- )
432
+ raise errors.APIError("API error occurred", http_res, http_res_text)
469
433
 
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
- )
434
+ raise errors.APIError("Unexpected response received", http_res)
478
435
 
479
436
  def update(
480
437
  self,
@@ -556,31 +513,20 @@ class LanguageGroups(BaseSDK):
556
513
 
557
514
  response_data: Any = None
558
515
  if utils.match_response(http_res, "200", "application/json"):
559
- return utils.unmarshal_json(http_res.text, models.LanguageGroupResponse)
516
+ return unmarshal_json_response(models.LanguageGroupResponse, http_res)
560
517
  if utils.match_response(http_res, "422", "application/json"):
561
- response_data = utils.unmarshal_json(
562
- http_res.text, models.HTTPValidationErrorData
518
+ response_data = unmarshal_json_response(
519
+ errors.HTTPValidationErrorData, http_res
563
520
  )
564
- raise models.HTTPValidationError(data=response_data)
521
+ raise errors.HTTPValidationError(response_data, http_res)
565
522
  if utils.match_response(http_res, "4XX", "*"):
566
523
  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
- )
524
+ raise errors.APIError("API error occurred", http_res, http_res_text)
570
525
  if utils.match_response(http_res, "5XX", "*"):
571
526
  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
- )
527
+ raise errors.APIError("API error occurred", http_res, http_res_text)
575
528
 
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
- )
529
+ raise errors.APIError("Unexpected response received", http_res)
584
530
 
585
531
  async def update_async(
586
532
  self,
@@ -662,31 +608,20 @@ class LanguageGroups(BaseSDK):
662
608
 
663
609
  response_data: Any = None
664
610
  if utils.match_response(http_res, "200", "application/json"):
665
- return utils.unmarshal_json(http_res.text, models.LanguageGroupResponse)
611
+ return unmarshal_json_response(models.LanguageGroupResponse, http_res)
666
612
  if utils.match_response(http_res, "422", "application/json"):
667
- response_data = utils.unmarshal_json(
668
- http_res.text, models.HTTPValidationErrorData
613
+ response_data = unmarshal_json_response(
614
+ errors.HTTPValidationErrorData, http_res
669
615
  )
670
- raise models.HTTPValidationError(data=response_data)
616
+ raise errors.HTTPValidationError(response_data, http_res)
671
617
  if utils.match_response(http_res, "4XX", "*"):
672
618
  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
- )
619
+ raise errors.APIError("API error occurred", http_res, http_res_text)
676
620
  if utils.match_response(http_res, "5XX", "*"):
677
621
  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
- )
622
+ raise errors.APIError("API error occurred", http_res, http_res_text)
681
623
 
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
- )
624
+ raise errors.APIError("Unexpected response received", http_res)
690
625
 
691
626
  def get_by_id(
692
627
  self,
@@ -762,31 +697,20 @@ class LanguageGroups(BaseSDK):
762
697
 
763
698
  response_data: Any = None
764
699
  if utils.match_response(http_res, "200", "application/json"):
765
- return utils.unmarshal_json(http_res.text, models.LanguageGroupResponse)
700
+ return unmarshal_json_response(models.LanguageGroupResponse, http_res)
766
701
  if utils.match_response(http_res, "422", "application/json"):
767
- response_data = utils.unmarshal_json(
768
- http_res.text, models.HTTPValidationErrorData
702
+ response_data = unmarshal_json_response(
703
+ errors.HTTPValidationErrorData, http_res
769
704
  )
770
- raise models.HTTPValidationError(data=response_data)
705
+ raise errors.HTTPValidationError(response_data, http_res)
771
706
  if utils.match_response(http_res, "4XX", "*"):
772
707
  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
- )
708
+ raise errors.APIError("API error occurred", http_res, http_res_text)
776
709
  if utils.match_response(http_res, "5XX", "*"):
777
710
  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
- )
711
+ raise errors.APIError("API error occurred", http_res, http_res_text)
781
712
 
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
- )
713
+ raise errors.APIError("Unexpected response received", http_res)
790
714
 
791
715
  async def get_by_id_async(
792
716
  self,
@@ -862,31 +786,20 @@ class LanguageGroups(BaseSDK):
862
786
 
863
787
  response_data: Any = None
864
788
  if utils.match_response(http_res, "200", "application/json"):
865
- return utils.unmarshal_json(http_res.text, models.LanguageGroupResponse)
789
+ return unmarshal_json_response(models.LanguageGroupResponse, http_res)
866
790
  if utils.match_response(http_res, "422", "application/json"):
867
- response_data = utils.unmarshal_json(
868
- http_res.text, models.HTTPValidationErrorData
791
+ response_data = unmarshal_json_response(
792
+ errors.HTTPValidationErrorData, http_res
869
793
  )
870
- raise models.HTTPValidationError(data=response_data)
794
+ raise errors.HTTPValidationError(response_data, http_res)
871
795
  if utils.match_response(http_res, "4XX", "*"):
872
796
  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
- )
797
+ raise errors.APIError("API error occurred", http_res, http_res_text)
876
798
  if utils.match_response(http_res, "5XX", "*"):
877
799
  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
- )
800
+ raise errors.APIError("API error occurred", http_res, http_res_text)
881
801
 
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
- )
802
+ raise errors.APIError("Unexpected response received", http_res)
890
803
 
891
804
  def delete(
892
805
  self,
@@ -965,31 +878,20 @@ class LanguageGroups(BaseSDK):
965
878
 
966
879
  response_data: Any = None
967
880
  if utils.match_response(http_res, "200", "application/json"):
968
- return utils.unmarshal_json(http_res.text, Any)
881
+ return unmarshal_json_response(Any, http_res)
969
882
  if utils.match_response(http_res, "422", "application/json"):
970
- response_data = utils.unmarshal_json(
971
- http_res.text, models.HTTPValidationErrorData
883
+ response_data = unmarshal_json_response(
884
+ errors.HTTPValidationErrorData, http_res
972
885
  )
973
- raise models.HTTPValidationError(data=response_data)
886
+ raise errors.HTTPValidationError(response_data, http_res)
974
887
  if utils.match_response(http_res, "4XX", "*"):
975
888
  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
- )
889
+ raise errors.APIError("API error occurred", http_res, http_res_text)
979
890
  if utils.match_response(http_res, "5XX", "*"):
980
891
  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
- )
892
+ raise errors.APIError("API error occurred", http_res, http_res_text)
984
893
 
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
- )
894
+ raise errors.APIError("Unexpected response received", http_res)
993
895
 
994
896
  async def delete_async(
995
897
  self,
@@ -1068,31 +970,20 @@ class LanguageGroups(BaseSDK):
1068
970
 
1069
971
  response_data: Any = None
1070
972
  if utils.match_response(http_res, "200", "application/json"):
1071
- return utils.unmarshal_json(http_res.text, Any)
973
+ return unmarshal_json_response(Any, http_res)
1072
974
  if utils.match_response(http_res, "422", "application/json"):
1073
- response_data = utils.unmarshal_json(
1074
- http_res.text, models.HTTPValidationErrorData
975
+ response_data = unmarshal_json_response(
976
+ errors.HTTPValidationErrorData, http_res
1075
977
  )
1076
- raise models.HTTPValidationError(data=response_data)
978
+ raise errors.HTTPValidationError(response_data, http_res)
1077
979
  if utils.match_response(http_res, "4XX", "*"):
1078
980
  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
- )
981
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1082
982
  if utils.match_response(http_res, "5XX", "*"):
1083
983
  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
- )
984
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1087
985
 
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
- )
986
+ raise errors.APIError("Unexpected response received", http_res)
1096
987
 
1097
988
  def language_groups_create_voice_sample(
1098
989
  self,
@@ -1177,29 +1068,19 @@ class LanguageGroups(BaseSDK):
1177
1068
  return http_res
1178
1069
  if utils.match_response(http_res, "422", "application/json"):
1179
1070
  http_res_text = utils.stream_to_text(http_res)
1180
- response_data = utils.unmarshal_json(
1181
- http_res_text, models.HTTPValidationErrorData
1071
+ response_data = unmarshal_json_response(
1072
+ errors.HTTPValidationErrorData, http_res, http_res_text
1182
1073
  )
1183
- raise models.HTTPValidationError(data=response_data)
1074
+ raise errors.HTTPValidationError(response_data, http_res, http_res_text)
1184
1075
  if utils.match_response(http_res, "4XX", "*"):
1185
1076
  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
- )
1077
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1189
1078
  if utils.match_response(http_res, "5XX", "*"):
1190
1079
  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
- )
1080
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1194
1081
 
1195
- content_type = http_res.headers.get("Content-Type")
1196
1082
  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
- )
1083
+ raise errors.APIError("Unexpected response received", http_res, http_res_text)
1203
1084
 
1204
1085
  async def language_groups_create_voice_sample_async(
1205
1086
  self,
@@ -1284,26 +1165,16 @@ class LanguageGroups(BaseSDK):
1284
1165
  return http_res
1285
1166
  if utils.match_response(http_res, "422", "application/json"):
1286
1167
  http_res_text = await utils.stream_to_text_async(http_res)
1287
- response_data = utils.unmarshal_json(
1288
- http_res_text, models.HTTPValidationErrorData
1168
+ response_data = unmarshal_json_response(
1169
+ errors.HTTPValidationErrorData, http_res, http_res_text
1289
1170
  )
1290
- raise models.HTTPValidationError(data=response_data)
1171
+ raise errors.HTTPValidationError(response_data, http_res, http_res_text)
1291
1172
  if utils.match_response(http_res, "4XX", "*"):
1292
1173
  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
- )
1174
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1296
1175
  if utils.match_response(http_res, "5XX", "*"):
1297
1176
  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
- )
1177
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1301
1178
 
1302
- content_type = http_res.headers.get("Content-Type")
1303
1179
  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
- )
1180
+ raise errors.APIError("Unexpected response received", http_res, http_res_text)
syllable_sdk/latency.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
9
10
 
10
11
 
@@ -81,31 +82,20 @@ class Latency(BaseSDK):
81
82
 
82
83
  response_data: Any = None
83
84
  if utils.match_response(http_res, "200", "application/json"):
84
- return utils.unmarshal_json(http_res.text, models.InspectLatencyResponse)
85
+ return unmarshal_json_response(models.InspectLatencyResponse, http_res)
85
86
  if utils.match_response(http_res, "422", "application/json"):
86
- response_data = utils.unmarshal_json(
87
- http_res.text, models.HTTPValidationErrorData
87
+ response_data = unmarshal_json_response(
88
+ errors.HTTPValidationErrorData, http_res
88
89
  )
89
- raise models.HTTPValidationError(data=response_data)
90
+ raise errors.HTTPValidationError(response_data, http_res)
90
91
  if utils.match_response(http_res, "4XX", "*"):
91
92
  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
- )
93
+ raise errors.APIError("API error occurred", http_res, http_res_text)
95
94
  if utils.match_response(http_res, "5XX", "*"):
96
95
  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
- )
96
+ raise errors.APIError("API error occurred", http_res, http_res_text)
100
97
 
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
- )
98
+ raise errors.APIError("Unexpected response received", http_res)
109
99
 
110
100
  async def get_by_id_async(
111
101
  self,
@@ -179,28 +169,17 @@ class Latency(BaseSDK):
179
169
 
180
170
  response_data: Any = None
181
171
  if utils.match_response(http_res, "200", "application/json"):
182
- return utils.unmarshal_json(http_res.text, models.InspectLatencyResponse)
172
+ return unmarshal_json_response(models.InspectLatencyResponse, http_res)
183
173
  if utils.match_response(http_res, "422", "application/json"):
184
- response_data = utils.unmarshal_json(
185
- http_res.text, models.HTTPValidationErrorData
174
+ response_data = unmarshal_json_response(
175
+ errors.HTTPValidationErrorData, http_res
186
176
  )
187
- raise models.HTTPValidationError(data=response_data)
177
+ raise errors.HTTPValidationError(response_data, http_res)
188
178
  if utils.match_response(http_res, "4XX", "*"):
189
179
  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
- )
180
+ raise errors.APIError("API error occurred", http_res, http_res_text)
193
181
  if utils.match_response(http_res, "5XX", "*"):
194
182
  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
- )
183
+ raise errors.APIError("API error occurred", http_res, http_res_text)
198
184
 
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
- )
185
+ 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",