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
@@ -1,10 +1,11 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from syllable_sdk import models, utils
4
+ from syllable_sdk import errors, models, utils
5
5
  from syllable_sdk._hooks import HookContext
6
6
  from syllable_sdk.types import BaseModel, OptionalNullable, UNSET
7
7
  from syllable_sdk.utils import get_security_from_env
8
+ from syllable_sdk.utils.unmarshal_json_response import unmarshal_json_response
8
9
  from typing import Any, List, Mapping, Optional, Union, cast
9
10
 
10
11
 
@@ -109,33 +110,22 @@ class InsightsTools(BaseSDK):
109
110
 
110
111
  response_data: Any = None
111
112
  if utils.match_response(http_res, "200", "application/json"):
112
- return utils.unmarshal_json(
113
- http_res.text, models.ListResponseInsightToolOutput
113
+ return unmarshal_json_response(
114
+ models.ListResponseInsightToolOutput, http_res
114
115
  )
115
116
  if utils.match_response(http_res, "422", "application/json"):
116
- response_data = utils.unmarshal_json(
117
- http_res.text, models.HTTPValidationErrorData
117
+ response_data = unmarshal_json_response(
118
+ errors.HTTPValidationErrorData, http_res
118
119
  )
119
- raise models.HTTPValidationError(data=response_data)
120
+ raise errors.HTTPValidationError(response_data, http_res)
120
121
  if utils.match_response(http_res, "4XX", "*"):
121
122
  http_res_text = utils.stream_to_text(http_res)
122
- raise models.APIError(
123
- "API error occurred", http_res.status_code, http_res_text, http_res
124
- )
123
+ raise errors.APIError("API error occurred", http_res, http_res_text)
125
124
  if utils.match_response(http_res, "5XX", "*"):
126
125
  http_res_text = utils.stream_to_text(http_res)
127
- raise models.APIError(
128
- "API error occurred", http_res.status_code, http_res_text, http_res
129
- )
126
+ raise errors.APIError("API error occurred", http_res, http_res_text)
130
127
 
131
- content_type = http_res.headers.get("Content-Type")
132
- http_res_text = utils.stream_to_text(http_res)
133
- raise models.APIError(
134
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
135
- http_res.status_code,
136
- http_res_text,
137
- http_res,
138
- )
128
+ raise errors.APIError("Unexpected response received", http_res)
139
129
 
140
130
  async def list_async(
141
131
  self,
@@ -235,33 +225,22 @@ class InsightsTools(BaseSDK):
235
225
 
236
226
  response_data: Any = None
237
227
  if utils.match_response(http_res, "200", "application/json"):
238
- return utils.unmarshal_json(
239
- http_res.text, models.ListResponseInsightToolOutput
228
+ return unmarshal_json_response(
229
+ models.ListResponseInsightToolOutput, http_res
240
230
  )
241
231
  if utils.match_response(http_res, "422", "application/json"):
242
- response_data = utils.unmarshal_json(
243
- http_res.text, models.HTTPValidationErrorData
232
+ response_data = unmarshal_json_response(
233
+ errors.HTTPValidationErrorData, http_res
244
234
  )
245
- raise models.HTTPValidationError(data=response_data)
235
+ raise errors.HTTPValidationError(response_data, http_res)
246
236
  if utils.match_response(http_res, "4XX", "*"):
247
237
  http_res_text = await utils.stream_to_text_async(http_res)
248
- raise models.APIError(
249
- "API error occurred", http_res.status_code, http_res_text, http_res
250
- )
238
+ raise errors.APIError("API error occurred", http_res, http_res_text)
251
239
  if utils.match_response(http_res, "5XX", "*"):
252
240
  http_res_text = await utils.stream_to_text_async(http_res)
253
- raise models.APIError(
254
- "API error occurred", http_res.status_code, http_res_text, http_res
255
- )
241
+ raise errors.APIError("API error occurred", http_res, http_res_text)
256
242
 
257
- content_type = http_res.headers.get("Content-Type")
258
- http_res_text = await utils.stream_to_text_async(http_res)
259
- raise models.APIError(
260
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
261
- http_res.status_code,
262
- http_res_text,
263
- http_res,
264
- )
243
+ raise errors.APIError("Unexpected response received", http_res)
265
244
 
266
245
  def create(
267
246
  self,
@@ -340,31 +319,20 @@ class InsightsTools(BaseSDK):
340
319
 
341
320
  response_data: Any = None
342
321
  if utils.match_response(http_res, "200", "application/json"):
343
- return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
322
+ return unmarshal_json_response(models.InsightToolOutput, http_res)
344
323
  if utils.match_response(http_res, "422", "application/json"):
345
- response_data = utils.unmarshal_json(
346
- http_res.text, models.HTTPValidationErrorData
324
+ response_data = unmarshal_json_response(
325
+ errors.HTTPValidationErrorData, http_res
347
326
  )
348
- raise models.HTTPValidationError(data=response_data)
327
+ raise errors.HTTPValidationError(response_data, http_res)
349
328
  if utils.match_response(http_res, ["400", "4XX"], "*"):
350
329
  http_res_text = utils.stream_to_text(http_res)
351
- raise models.APIError(
352
- "API error occurred", http_res.status_code, http_res_text, http_res
353
- )
330
+ raise errors.APIError("API error occurred", http_res, http_res_text)
354
331
  if utils.match_response(http_res, ["500", "5XX"], "*"):
355
332
  http_res_text = utils.stream_to_text(http_res)
356
- raise models.APIError(
357
- "API error occurred", http_res.status_code, http_res_text, http_res
358
- )
333
+ raise errors.APIError("API error occurred", http_res, http_res_text)
359
334
 
360
- content_type = http_res.headers.get("Content-Type")
361
- http_res_text = utils.stream_to_text(http_res)
362
- raise models.APIError(
363
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
364
- http_res.status_code,
365
- http_res_text,
366
- http_res,
367
- )
335
+ raise errors.APIError("Unexpected response received", http_res)
368
336
 
369
337
  async def create_async(
370
338
  self,
@@ -443,31 +411,20 @@ class InsightsTools(BaseSDK):
443
411
 
444
412
  response_data: Any = None
445
413
  if utils.match_response(http_res, "200", "application/json"):
446
- return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
414
+ return unmarshal_json_response(models.InsightToolOutput, http_res)
447
415
  if utils.match_response(http_res, "422", "application/json"):
448
- response_data = utils.unmarshal_json(
449
- http_res.text, models.HTTPValidationErrorData
416
+ response_data = unmarshal_json_response(
417
+ errors.HTTPValidationErrorData, http_res
450
418
  )
451
- raise models.HTTPValidationError(data=response_data)
419
+ raise errors.HTTPValidationError(response_data, http_res)
452
420
  if utils.match_response(http_res, ["400", "4XX"], "*"):
453
421
  http_res_text = await utils.stream_to_text_async(http_res)
454
- raise models.APIError(
455
- "API error occurred", http_res.status_code, http_res_text, http_res
456
- )
422
+ raise errors.APIError("API error occurred", http_res, http_res_text)
457
423
  if utils.match_response(http_res, ["500", "5XX"], "*"):
458
424
  http_res_text = await utils.stream_to_text_async(http_res)
459
- raise models.APIError(
460
- "API error occurred", http_res.status_code, http_res_text, http_res
461
- )
425
+ raise errors.APIError("API error occurred", http_res, http_res_text)
462
426
 
463
- content_type = http_res.headers.get("Content-Type")
464
- http_res_text = await utils.stream_to_text_async(http_res)
465
- raise models.APIError(
466
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
467
- http_res.status_code,
468
- http_res_text,
469
- http_res,
470
- )
427
+ raise errors.APIError("Unexpected response received", http_res)
471
428
 
472
429
  def get_by_id(
473
430
  self,
@@ -543,31 +500,20 @@ class InsightsTools(BaseSDK):
543
500
 
544
501
  response_data: Any = None
545
502
  if utils.match_response(http_res, "200", "application/json"):
546
- return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
503
+ return unmarshal_json_response(models.InsightToolOutput, http_res)
547
504
  if utils.match_response(http_res, "422", "application/json"):
548
- response_data = utils.unmarshal_json(
549
- http_res.text, models.HTTPValidationErrorData
505
+ response_data = unmarshal_json_response(
506
+ errors.HTTPValidationErrorData, http_res
550
507
  )
551
- raise models.HTTPValidationError(data=response_data)
508
+ raise errors.HTTPValidationError(response_data, http_res)
552
509
  if utils.match_response(http_res, "4XX", "*"):
553
510
  http_res_text = utils.stream_to_text(http_res)
554
- raise models.APIError(
555
- "API error occurred", http_res.status_code, http_res_text, http_res
556
- )
511
+ raise errors.APIError("API error occurred", http_res, http_res_text)
557
512
  if utils.match_response(http_res, "5XX", "*"):
558
513
  http_res_text = utils.stream_to_text(http_res)
559
- raise models.APIError(
560
- "API error occurred", http_res.status_code, http_res_text, http_res
561
- )
514
+ raise errors.APIError("API error occurred", http_res, http_res_text)
562
515
 
563
- content_type = http_res.headers.get("Content-Type")
564
- http_res_text = utils.stream_to_text(http_res)
565
- raise models.APIError(
566
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
567
- http_res.status_code,
568
- http_res_text,
569
- http_res,
570
- )
516
+ raise errors.APIError("Unexpected response received", http_res)
571
517
 
572
518
  async def get_by_id_async(
573
519
  self,
@@ -643,31 +589,20 @@ class InsightsTools(BaseSDK):
643
589
 
644
590
  response_data: Any = None
645
591
  if utils.match_response(http_res, "200", "application/json"):
646
- return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
592
+ return unmarshal_json_response(models.InsightToolOutput, http_res)
647
593
  if utils.match_response(http_res, "422", "application/json"):
648
- response_data = utils.unmarshal_json(
649
- http_res.text, models.HTTPValidationErrorData
594
+ response_data = unmarshal_json_response(
595
+ errors.HTTPValidationErrorData, http_res
650
596
  )
651
- raise models.HTTPValidationError(data=response_data)
597
+ raise errors.HTTPValidationError(response_data, http_res)
652
598
  if utils.match_response(http_res, "4XX", "*"):
653
599
  http_res_text = await utils.stream_to_text_async(http_res)
654
- raise models.APIError(
655
- "API error occurred", http_res.status_code, http_res_text, http_res
656
- )
600
+ raise errors.APIError("API error occurred", http_res, http_res_text)
657
601
  if utils.match_response(http_res, "5XX", "*"):
658
602
  http_res_text = await utils.stream_to_text_async(http_res)
659
- raise models.APIError(
660
- "API error occurred", http_res.status_code, http_res_text, http_res
661
- )
603
+ raise errors.APIError("API error occurred", http_res, http_res_text)
662
604
 
663
- content_type = http_res.headers.get("Content-Type")
664
- http_res_text = await utils.stream_to_text_async(http_res)
665
- raise models.APIError(
666
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
667
- http_res.status_code,
668
- http_res_text,
669
- http_res,
670
- )
605
+ raise errors.APIError("Unexpected response received", http_res)
671
606
 
672
607
  def delete(
673
608
  self,
@@ -743,31 +678,20 @@ class InsightsTools(BaseSDK):
743
678
 
744
679
  response_data: Any = None
745
680
  if utils.match_response(http_res, "200", "application/json"):
746
- return utils.unmarshal_json(http_res.text, Any)
681
+ return unmarshal_json_response(Any, http_res)
747
682
  if utils.match_response(http_res, "422", "application/json"):
748
- response_data = utils.unmarshal_json(
749
- http_res.text, models.HTTPValidationErrorData
683
+ response_data = unmarshal_json_response(
684
+ errors.HTTPValidationErrorData, http_res
750
685
  )
751
- raise models.HTTPValidationError(data=response_data)
686
+ raise errors.HTTPValidationError(response_data, http_res)
752
687
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
753
688
  http_res_text = utils.stream_to_text(http_res)
754
- raise models.APIError(
755
- "API error occurred", http_res.status_code, http_res_text, http_res
756
- )
689
+ raise errors.APIError("API error occurred", http_res, http_res_text)
757
690
  if utils.match_response(http_res, ["500", "5XX"], "*"):
758
691
  http_res_text = utils.stream_to_text(http_res)
759
- raise models.APIError(
760
- "API error occurred", http_res.status_code, http_res_text, http_res
761
- )
692
+ raise errors.APIError("API error occurred", http_res, http_res_text)
762
693
 
763
- content_type = http_res.headers.get("Content-Type")
764
- http_res_text = utils.stream_to_text(http_res)
765
- raise models.APIError(
766
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
767
- http_res.status_code,
768
- http_res_text,
769
- http_res,
770
- )
694
+ raise errors.APIError("Unexpected response received", http_res)
771
695
 
772
696
  async def delete_async(
773
697
  self,
@@ -843,31 +767,20 @@ class InsightsTools(BaseSDK):
843
767
 
844
768
  response_data: Any = None
845
769
  if utils.match_response(http_res, "200", "application/json"):
846
- return utils.unmarshal_json(http_res.text, Any)
770
+ return unmarshal_json_response(Any, http_res)
847
771
  if utils.match_response(http_res, "422", "application/json"):
848
- response_data = utils.unmarshal_json(
849
- http_res.text, models.HTTPValidationErrorData
772
+ response_data = unmarshal_json_response(
773
+ errors.HTTPValidationErrorData, http_res
850
774
  )
851
- raise models.HTTPValidationError(data=response_data)
775
+ raise errors.HTTPValidationError(response_data, http_res)
852
776
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
853
777
  http_res_text = await utils.stream_to_text_async(http_res)
854
- raise models.APIError(
855
- "API error occurred", http_res.status_code, http_res_text, http_res
856
- )
778
+ raise errors.APIError("API error occurred", http_res, http_res_text)
857
779
  if utils.match_response(http_res, ["500", "5XX"], "*"):
858
780
  http_res_text = await utils.stream_to_text_async(http_res)
859
- raise models.APIError(
860
- "API error occurred", http_res.status_code, http_res_text, http_res
861
- )
781
+ raise errors.APIError("API error occurred", http_res, http_res_text)
862
782
 
863
- content_type = http_res.headers.get("Content-Type")
864
- http_res_text = await utils.stream_to_text_async(http_res)
865
- raise models.APIError(
866
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
867
- http_res.status_code,
868
- http_res_text,
869
- http_res,
870
- )
783
+ raise errors.APIError("Unexpected response received", http_res)
871
784
 
872
785
  def update(
873
786
  self,
@@ -957,31 +870,20 @@ class InsightsTools(BaseSDK):
957
870
 
958
871
  response_data: Any = None
959
872
  if utils.match_response(http_res, "200", "application/json"):
960
- return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
873
+ return unmarshal_json_response(models.InsightToolOutput, http_res)
961
874
  if utils.match_response(http_res, "422", "application/json"):
962
- response_data = utils.unmarshal_json(
963
- http_res.text, models.HTTPValidationErrorData
875
+ response_data = unmarshal_json_response(
876
+ errors.HTTPValidationErrorData, http_res
964
877
  )
965
- raise models.HTTPValidationError(data=response_data)
878
+ raise errors.HTTPValidationError(response_data, http_res)
966
879
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
967
880
  http_res_text = utils.stream_to_text(http_res)
968
- raise models.APIError(
969
- "API error occurred", http_res.status_code, http_res_text, http_res
970
- )
881
+ raise errors.APIError("API error occurred", http_res, http_res_text)
971
882
  if utils.match_response(http_res, ["500", "5XX"], "*"):
972
883
  http_res_text = utils.stream_to_text(http_res)
973
- raise models.APIError(
974
- "API error occurred", http_res.status_code, http_res_text, http_res
975
- )
884
+ raise errors.APIError("API error occurred", http_res, http_res_text)
976
885
 
977
- content_type = http_res.headers.get("Content-Type")
978
- http_res_text = utils.stream_to_text(http_res)
979
- raise models.APIError(
980
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
981
- http_res.status_code,
982
- http_res_text,
983
- http_res,
984
- )
886
+ raise errors.APIError("Unexpected response received", http_res)
985
887
 
986
888
  async def update_async(
987
889
  self,
@@ -1071,31 +973,20 @@ class InsightsTools(BaseSDK):
1071
973
 
1072
974
  response_data: Any = None
1073
975
  if utils.match_response(http_res, "200", "application/json"):
1074
- return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
976
+ return unmarshal_json_response(models.InsightToolOutput, http_res)
1075
977
  if utils.match_response(http_res, "422", "application/json"):
1076
- response_data = utils.unmarshal_json(
1077
- http_res.text, models.HTTPValidationErrorData
978
+ response_data = unmarshal_json_response(
979
+ errors.HTTPValidationErrorData, http_res
1078
980
  )
1079
- raise models.HTTPValidationError(data=response_data)
981
+ raise errors.HTTPValidationError(response_data, http_res)
1080
982
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
1081
983
  http_res_text = await utils.stream_to_text_async(http_res)
1082
- raise models.APIError(
1083
- "API error occurred", http_res.status_code, http_res_text, http_res
1084
- )
984
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1085
985
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1086
986
  http_res_text = await utils.stream_to_text_async(http_res)
1087
- raise models.APIError(
1088
- "API error occurred", http_res.status_code, http_res_text, http_res
1089
- )
987
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1090
988
 
1091
- content_type = http_res.headers.get("Content-Type")
1092
- http_res_text = await utils.stream_to_text_async(http_res)
1093
- raise models.APIError(
1094
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1095
- http_res.status_code,
1096
- http_res_text,
1097
- http_res,
1098
- )
989
+ raise errors.APIError("Unexpected response received", http_res)
1099
990
 
1100
991
  def insights_tool_test(
1101
992
  self,
@@ -1176,31 +1067,20 @@ class InsightsTools(BaseSDK):
1176
1067
 
1177
1068
  response_data: Any = None
1178
1069
  if utils.match_response(http_res, "200", "application/json"):
1179
- return utils.unmarshal_json(http_res.text, Any)
1070
+ return unmarshal_json_response(Any, http_res)
1180
1071
  if utils.match_response(http_res, "422", "application/json"):
1181
- response_data = utils.unmarshal_json(
1182
- http_res.text, models.HTTPValidationErrorData
1072
+ response_data = unmarshal_json_response(
1073
+ errors.HTTPValidationErrorData, http_res
1183
1074
  )
1184
- raise models.HTTPValidationError(data=response_data)
1075
+ raise errors.HTTPValidationError(response_data, http_res)
1185
1076
  if utils.match_response(http_res, ["400", "404", "4XX"], "*"):
1186
1077
  http_res_text = utils.stream_to_text(http_res)
1187
- raise models.APIError(
1188
- "API error occurred", http_res.status_code, http_res_text, http_res
1189
- )
1078
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1190
1079
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1191
1080
  http_res_text = utils.stream_to_text(http_res)
1192
- raise models.APIError(
1193
- "API error occurred", http_res.status_code, http_res_text, http_res
1194
- )
1081
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1195
1082
 
1196
- content_type = http_res.headers.get("Content-Type")
1197
- http_res_text = utils.stream_to_text(http_res)
1198
- raise models.APIError(
1199
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1200
- http_res.status_code,
1201
- http_res_text,
1202
- http_res,
1203
- )
1083
+ raise errors.APIError("Unexpected response received", http_res)
1204
1084
 
1205
1085
  async def insights_tool_test_async(
1206
1086
  self,
@@ -1281,31 +1161,20 @@ class InsightsTools(BaseSDK):
1281
1161
 
1282
1162
  response_data: Any = None
1283
1163
  if utils.match_response(http_res, "200", "application/json"):
1284
- return utils.unmarshal_json(http_res.text, Any)
1164
+ return unmarshal_json_response(Any, http_res)
1285
1165
  if utils.match_response(http_res, "422", "application/json"):
1286
- response_data = utils.unmarshal_json(
1287
- http_res.text, models.HTTPValidationErrorData
1166
+ response_data = unmarshal_json_response(
1167
+ errors.HTTPValidationErrorData, http_res
1288
1168
  )
1289
- raise models.HTTPValidationError(data=response_data)
1169
+ raise errors.HTTPValidationError(response_data, http_res)
1290
1170
  if utils.match_response(http_res, ["400", "404", "4XX"], "*"):
1291
1171
  http_res_text = await utils.stream_to_text_async(http_res)
1292
- raise models.APIError(
1293
- "API error occurred", http_res.status_code, http_res_text, http_res
1294
- )
1172
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1295
1173
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1296
1174
  http_res_text = await utils.stream_to_text_async(http_res)
1297
- raise models.APIError(
1298
- "API error occurred", http_res.status_code, http_res_text, http_res
1299
- )
1175
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1300
1176
 
1301
- content_type = http_res.headers.get("Content-Type")
1302
- http_res_text = await utils.stream_to_text_async(http_res)
1303
- raise models.APIError(
1304
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1305
- http_res.status_code,
1306
- http_res_text,
1307
- http_res,
1308
- )
1177
+ raise errors.APIError("Unexpected response received", http_res)
1309
1178
 
1310
1179
  def insight_tool_get_definitions(
1311
1180
  self,
@@ -1373,28 +1242,15 @@ class InsightsTools(BaseSDK):
1373
1242
  )
1374
1243
 
1375
1244
  if utils.match_response(http_res, "200", "application/json"):
1376
- return utils.unmarshal_json(
1377
- http_res.text, List[models.InsightToolDefinition]
1378
- )
1245
+ return unmarshal_json_response(List[models.InsightToolDefinition], http_res)
1379
1246
  if utils.match_response(http_res, "4XX", "*"):
1380
1247
  http_res_text = utils.stream_to_text(http_res)
1381
- raise models.APIError(
1382
- "API error occurred", http_res.status_code, http_res_text, http_res
1383
- )
1248
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1384
1249
  if utils.match_response(http_res, "5XX", "*"):
1385
1250
  http_res_text = utils.stream_to_text(http_res)
1386
- raise models.APIError(
1387
- "API error occurred", http_res.status_code, http_res_text, http_res
1388
- )
1251
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1389
1252
 
1390
- content_type = http_res.headers.get("Content-Type")
1391
- http_res_text = utils.stream_to_text(http_res)
1392
- raise models.APIError(
1393
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1394
- http_res.status_code,
1395
- http_res_text,
1396
- http_res,
1397
- )
1253
+ raise errors.APIError("Unexpected response received", http_res)
1398
1254
 
1399
1255
  async def insight_tool_get_definitions_async(
1400
1256
  self,
@@ -1462,25 +1318,12 @@ class InsightsTools(BaseSDK):
1462
1318
  )
1463
1319
 
1464
1320
  if utils.match_response(http_res, "200", "application/json"):
1465
- return utils.unmarshal_json(
1466
- http_res.text, List[models.InsightToolDefinition]
1467
- )
1321
+ return unmarshal_json_response(List[models.InsightToolDefinition], http_res)
1468
1322
  if utils.match_response(http_res, "4XX", "*"):
1469
1323
  http_res_text = await utils.stream_to_text_async(http_res)
1470
- raise models.APIError(
1471
- "API error occurred", http_res.status_code, http_res_text, http_res
1472
- )
1324
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1473
1325
  if utils.match_response(http_res, "5XX", "*"):
1474
1326
  http_res_text = await utils.stream_to_text_async(http_res)
1475
- raise models.APIError(
1476
- "API error occurred", http_res.status_code, http_res_text, http_res
1477
- )
1327
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1478
1328
 
1479
- content_type = http_res.headers.get("Content-Type")
1480
- http_res_text = await utils.stream_to_text_async(http_res)
1481
- raise models.APIError(
1482
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1483
- http_res.status_code,
1484
- http_res_text,
1485
- http_res,
1486
- )
1329
+ raise errors.APIError("Unexpected response received", http_res)