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
@@ -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
@@ -109,33 +109,22 @@ class InsightsTools(BaseSDK):
109
109
 
110
110
  response_data: Any = None
111
111
  if utils.match_response(http_res, "200", "application/json"):
112
- return utils.unmarshal_json(
113
- http_res.text, models.ListResponseInsightToolOutput
112
+ return utils.unmarshal_json_response(
113
+ models.ListResponseInsightToolOutput, http_res
114
114
  )
115
115
  if utils.match_response(http_res, "422", "application/json"):
116
- response_data = utils.unmarshal_json(
117
- http_res.text, models.HTTPValidationErrorData
116
+ response_data = utils.unmarshal_json_response(
117
+ errors.HTTPValidationErrorData, http_res
118
118
  )
119
- raise models.HTTPValidationError(data=response_data)
119
+ raise errors.HTTPValidationError(response_data, http_res)
120
120
  if utils.match_response(http_res, "4XX", "*"):
121
121
  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
- )
122
+ raise errors.APIError("API error occurred", http_res, http_res_text)
125
123
  if utils.match_response(http_res, "5XX", "*"):
126
124
  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
- )
125
+ raise errors.APIError("API error occurred", http_res, http_res_text)
130
126
 
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
- )
127
+ raise errors.APIError("Unexpected response received", http_res)
139
128
 
140
129
  async def list_async(
141
130
  self,
@@ -235,33 +224,22 @@ class InsightsTools(BaseSDK):
235
224
 
236
225
  response_data: Any = None
237
226
  if utils.match_response(http_res, "200", "application/json"):
238
- return utils.unmarshal_json(
239
- http_res.text, models.ListResponseInsightToolOutput
227
+ return utils.unmarshal_json_response(
228
+ models.ListResponseInsightToolOutput, http_res
240
229
  )
241
230
  if utils.match_response(http_res, "422", "application/json"):
242
- response_data = utils.unmarshal_json(
243
- http_res.text, models.HTTPValidationErrorData
231
+ response_data = utils.unmarshal_json_response(
232
+ errors.HTTPValidationErrorData, http_res
244
233
  )
245
- raise models.HTTPValidationError(data=response_data)
234
+ raise errors.HTTPValidationError(response_data, http_res)
246
235
  if utils.match_response(http_res, "4XX", "*"):
247
236
  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
- )
237
+ raise errors.APIError("API error occurred", http_res, http_res_text)
251
238
  if utils.match_response(http_res, "5XX", "*"):
252
239
  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
- )
240
+ raise errors.APIError("API error occurred", http_res, http_res_text)
256
241
 
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
- )
242
+ raise errors.APIError("Unexpected response received", http_res)
265
243
 
266
244
  def create(
267
245
  self,
@@ -340,31 +318,20 @@ class InsightsTools(BaseSDK):
340
318
 
341
319
  response_data: Any = None
342
320
  if utils.match_response(http_res, "200", "application/json"):
343
- return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
321
+ return utils.unmarshal_json_response(models.InsightToolOutput, http_res)
344
322
  if utils.match_response(http_res, "422", "application/json"):
345
- response_data = utils.unmarshal_json(
346
- http_res.text, models.HTTPValidationErrorData
323
+ response_data = utils.unmarshal_json_response(
324
+ errors.HTTPValidationErrorData, http_res
347
325
  )
348
- raise models.HTTPValidationError(data=response_data)
326
+ raise errors.HTTPValidationError(response_data, http_res)
349
327
  if utils.match_response(http_res, ["400", "4XX"], "*"):
350
328
  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
- )
329
+ raise errors.APIError("API error occurred", http_res, http_res_text)
354
330
  if utils.match_response(http_res, ["500", "5XX"], "*"):
355
331
  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
- )
332
+ raise errors.APIError("API error occurred", http_res, http_res_text)
359
333
 
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
- )
334
+ raise errors.APIError("Unexpected response received", http_res)
368
335
 
369
336
  async def create_async(
370
337
  self,
@@ -443,31 +410,20 @@ class InsightsTools(BaseSDK):
443
410
 
444
411
  response_data: Any = None
445
412
  if utils.match_response(http_res, "200", "application/json"):
446
- return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
413
+ return utils.unmarshal_json_response(models.InsightToolOutput, http_res)
447
414
  if utils.match_response(http_res, "422", "application/json"):
448
- response_data = utils.unmarshal_json(
449
- http_res.text, models.HTTPValidationErrorData
415
+ response_data = utils.unmarshal_json_response(
416
+ errors.HTTPValidationErrorData, http_res
450
417
  )
451
- raise models.HTTPValidationError(data=response_data)
418
+ raise errors.HTTPValidationError(response_data, http_res)
452
419
  if utils.match_response(http_res, ["400", "4XX"], "*"):
453
420
  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
- )
421
+ raise errors.APIError("API error occurred", http_res, http_res_text)
457
422
  if utils.match_response(http_res, ["500", "5XX"], "*"):
458
423
  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
- )
424
+ raise errors.APIError("API error occurred", http_res, http_res_text)
462
425
 
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
- )
426
+ raise errors.APIError("Unexpected response received", http_res)
471
427
 
472
428
  def get_by_id(
473
429
  self,
@@ -543,31 +499,20 @@ class InsightsTools(BaseSDK):
543
499
 
544
500
  response_data: Any = None
545
501
  if utils.match_response(http_res, "200", "application/json"):
546
- return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
502
+ return utils.unmarshal_json_response(models.InsightToolOutput, http_res)
547
503
  if utils.match_response(http_res, "422", "application/json"):
548
- response_data = utils.unmarshal_json(
549
- http_res.text, models.HTTPValidationErrorData
504
+ response_data = utils.unmarshal_json_response(
505
+ errors.HTTPValidationErrorData, http_res
550
506
  )
551
- raise models.HTTPValidationError(data=response_data)
507
+ raise errors.HTTPValidationError(response_data, http_res)
552
508
  if utils.match_response(http_res, "4XX", "*"):
553
509
  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
- )
510
+ raise errors.APIError("API error occurred", http_res, http_res_text)
557
511
  if utils.match_response(http_res, "5XX", "*"):
558
512
  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
- )
513
+ raise errors.APIError("API error occurred", http_res, http_res_text)
562
514
 
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
- )
515
+ raise errors.APIError("Unexpected response received", http_res)
571
516
 
572
517
  async def get_by_id_async(
573
518
  self,
@@ -643,31 +588,20 @@ class InsightsTools(BaseSDK):
643
588
 
644
589
  response_data: Any = None
645
590
  if utils.match_response(http_res, "200", "application/json"):
646
- return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
591
+ return utils.unmarshal_json_response(models.InsightToolOutput, http_res)
647
592
  if utils.match_response(http_res, "422", "application/json"):
648
- response_data = utils.unmarshal_json(
649
- http_res.text, models.HTTPValidationErrorData
593
+ response_data = utils.unmarshal_json_response(
594
+ errors.HTTPValidationErrorData, http_res
650
595
  )
651
- raise models.HTTPValidationError(data=response_data)
596
+ raise errors.HTTPValidationError(response_data, http_res)
652
597
  if utils.match_response(http_res, "4XX", "*"):
653
598
  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
- )
599
+ raise errors.APIError("API error occurred", http_res, http_res_text)
657
600
  if utils.match_response(http_res, "5XX", "*"):
658
601
  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
- )
602
+ raise errors.APIError("API error occurred", http_res, http_res_text)
662
603
 
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
- )
604
+ raise errors.APIError("Unexpected response received", http_res)
671
605
 
672
606
  def delete(
673
607
  self,
@@ -743,31 +677,20 @@ class InsightsTools(BaseSDK):
743
677
 
744
678
  response_data: Any = None
745
679
  if utils.match_response(http_res, "200", "application/json"):
746
- return utils.unmarshal_json(http_res.text, Any)
680
+ return utils.unmarshal_json_response(Any, http_res)
747
681
  if utils.match_response(http_res, "422", "application/json"):
748
- response_data = utils.unmarshal_json(
749
- http_res.text, models.HTTPValidationErrorData
682
+ response_data = utils.unmarshal_json_response(
683
+ errors.HTTPValidationErrorData, http_res
750
684
  )
751
- raise models.HTTPValidationError(data=response_data)
685
+ raise errors.HTTPValidationError(response_data, http_res)
752
686
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
753
687
  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
- )
688
+ raise errors.APIError("API error occurred", http_res, http_res_text)
757
689
  if utils.match_response(http_res, ["500", "5XX"], "*"):
758
690
  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
- )
691
+ raise errors.APIError("API error occurred", http_res, http_res_text)
762
692
 
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
- )
693
+ raise errors.APIError("Unexpected response received", http_res)
771
694
 
772
695
  async def delete_async(
773
696
  self,
@@ -843,31 +766,20 @@ class InsightsTools(BaseSDK):
843
766
 
844
767
  response_data: Any = None
845
768
  if utils.match_response(http_res, "200", "application/json"):
846
- return utils.unmarshal_json(http_res.text, Any)
769
+ return utils.unmarshal_json_response(Any, http_res)
847
770
  if utils.match_response(http_res, "422", "application/json"):
848
- response_data = utils.unmarshal_json(
849
- http_res.text, models.HTTPValidationErrorData
771
+ response_data = utils.unmarshal_json_response(
772
+ errors.HTTPValidationErrorData, http_res
850
773
  )
851
- raise models.HTTPValidationError(data=response_data)
774
+ raise errors.HTTPValidationError(response_data, http_res)
852
775
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
853
776
  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
- )
777
+ raise errors.APIError("API error occurred", http_res, http_res_text)
857
778
  if utils.match_response(http_res, ["500", "5XX"], "*"):
858
779
  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
- )
780
+ raise errors.APIError("API error occurred", http_res, http_res_text)
862
781
 
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
- )
782
+ raise errors.APIError("Unexpected response received", http_res)
871
783
 
872
784
  def update(
873
785
  self,
@@ -957,31 +869,20 @@ class InsightsTools(BaseSDK):
957
869
 
958
870
  response_data: Any = None
959
871
  if utils.match_response(http_res, "200", "application/json"):
960
- return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
872
+ return utils.unmarshal_json_response(models.InsightToolOutput, http_res)
961
873
  if utils.match_response(http_res, "422", "application/json"):
962
- response_data = utils.unmarshal_json(
963
- http_res.text, models.HTTPValidationErrorData
874
+ response_data = utils.unmarshal_json_response(
875
+ errors.HTTPValidationErrorData, http_res
964
876
  )
965
- raise models.HTTPValidationError(data=response_data)
877
+ raise errors.HTTPValidationError(response_data, http_res)
966
878
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
967
879
  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
- )
880
+ raise errors.APIError("API error occurred", http_res, http_res_text)
971
881
  if utils.match_response(http_res, ["500", "5XX"], "*"):
972
882
  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
- )
883
+ raise errors.APIError("API error occurred", http_res, http_res_text)
976
884
 
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
- )
885
+ raise errors.APIError("Unexpected response received", http_res)
985
886
 
986
887
  async def update_async(
987
888
  self,
@@ -1071,31 +972,20 @@ class InsightsTools(BaseSDK):
1071
972
 
1072
973
  response_data: Any = None
1073
974
  if utils.match_response(http_res, "200", "application/json"):
1074
- return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
975
+ return utils.unmarshal_json_response(models.InsightToolOutput, http_res)
1075
976
  if utils.match_response(http_res, "422", "application/json"):
1076
- response_data = utils.unmarshal_json(
1077
- http_res.text, models.HTTPValidationErrorData
977
+ response_data = utils.unmarshal_json_response(
978
+ errors.HTTPValidationErrorData, http_res
1078
979
  )
1079
- raise models.HTTPValidationError(data=response_data)
980
+ raise errors.HTTPValidationError(response_data, http_res)
1080
981
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
1081
982
  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
- )
983
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1085
984
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1086
985
  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
- )
986
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1090
987
 
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
- )
988
+ raise errors.APIError("Unexpected response received", http_res)
1099
989
 
1100
990
  def insights_tool_test(
1101
991
  self,
@@ -1176,31 +1066,20 @@ class InsightsTools(BaseSDK):
1176
1066
 
1177
1067
  response_data: Any = None
1178
1068
  if utils.match_response(http_res, "200", "application/json"):
1179
- return utils.unmarshal_json(http_res.text, Any)
1069
+ return utils.unmarshal_json_response(Any, http_res)
1180
1070
  if utils.match_response(http_res, "422", "application/json"):
1181
- response_data = utils.unmarshal_json(
1182
- http_res.text, models.HTTPValidationErrorData
1071
+ response_data = utils.unmarshal_json_response(
1072
+ errors.HTTPValidationErrorData, http_res
1183
1073
  )
1184
- raise models.HTTPValidationError(data=response_data)
1074
+ raise errors.HTTPValidationError(response_data, http_res)
1185
1075
  if utils.match_response(http_res, ["400", "404", "4XX"], "*"):
1186
1076
  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
- )
1077
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1190
1078
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1191
1079
  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
- )
1080
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1195
1081
 
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
- )
1082
+ raise errors.APIError("Unexpected response received", http_res)
1204
1083
 
1205
1084
  async def insights_tool_test_async(
1206
1085
  self,
@@ -1281,31 +1160,20 @@ class InsightsTools(BaseSDK):
1281
1160
 
1282
1161
  response_data: Any = None
1283
1162
  if utils.match_response(http_res, "200", "application/json"):
1284
- return utils.unmarshal_json(http_res.text, Any)
1163
+ return utils.unmarshal_json_response(Any, http_res)
1285
1164
  if utils.match_response(http_res, "422", "application/json"):
1286
- response_data = utils.unmarshal_json(
1287
- http_res.text, models.HTTPValidationErrorData
1165
+ response_data = utils.unmarshal_json_response(
1166
+ errors.HTTPValidationErrorData, http_res
1288
1167
  )
1289
- raise models.HTTPValidationError(data=response_data)
1168
+ raise errors.HTTPValidationError(response_data, http_res)
1290
1169
  if utils.match_response(http_res, ["400", "404", "4XX"], "*"):
1291
1170
  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
- )
1171
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1295
1172
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1296
1173
  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
- )
1174
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1300
1175
 
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
- )
1176
+ raise errors.APIError("Unexpected response received", http_res)
1309
1177
 
1310
1178
  def insight_tool_get_definitions(
1311
1179
  self,
@@ -1373,28 +1241,17 @@ class InsightsTools(BaseSDK):
1373
1241
  )
1374
1242
 
1375
1243
  if utils.match_response(http_res, "200", "application/json"):
1376
- return utils.unmarshal_json(
1377
- http_res.text, List[models.InsightToolDefinition]
1244
+ return utils.unmarshal_json_response(
1245
+ List[models.InsightToolDefinition], http_res
1378
1246
  )
1379
1247
  if utils.match_response(http_res, "4XX", "*"):
1380
1248
  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
- )
1249
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1384
1250
  if utils.match_response(http_res, "5XX", "*"):
1385
1251
  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
- )
1252
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1389
1253
 
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
- )
1254
+ raise errors.APIError("Unexpected response received", http_res)
1398
1255
 
1399
1256
  async def insight_tool_get_definitions_async(
1400
1257
  self,
@@ -1462,25 +1319,14 @@ class InsightsTools(BaseSDK):
1462
1319
  )
1463
1320
 
1464
1321
  if utils.match_response(http_res, "200", "application/json"):
1465
- return utils.unmarshal_json(
1466
- http_res.text, List[models.InsightToolDefinition]
1322
+ return utils.unmarshal_json_response(
1323
+ List[models.InsightToolDefinition], http_res
1467
1324
  )
1468
1325
  if utils.match_response(http_res, "4XX", "*"):
1469
1326
  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
- )
1327
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1473
1328
  if utils.match_response(http_res, "5XX", "*"):
1474
1329
  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
- )
1330
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1478
1331
 
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
- )
1332
+ raise errors.APIError("Unexpected response received", http_res)