syllable-sdk 0.35.30__py3-none-any.whl → 0.35.32__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 (47) hide show
  1. syllable_sdk/_version.py +3 -3
  2. syllable_sdk/agents.py +210 -82
  3. syllable_sdk/basesdk.py +4 -4
  4. syllable_sdk/batches.py +328 -130
  5. syllable_sdk/campaigns.py +182 -72
  6. syllable_sdk/channels.py +72 -28
  7. syllable_sdk/conversations.py +36 -18
  8. syllable_sdk/custom_messages.py +182 -72
  9. syllable_sdk/dashboards.py +194 -66
  10. syllable_sdk/data_sources.py +182 -84
  11. syllable_sdk/events.py +36 -14
  12. syllable_sdk/folders.py +292 -120
  13. syllable_sdk/full_summary.py +36 -18
  14. syllable_sdk/incidents.py +214 -82
  15. syllable_sdk/insights_sdk.py +38 -16
  16. syllable_sdk/insights_tools.py +250 -96
  17. syllable_sdk/language_groups.py +214 -84
  18. syllable_sdk/latency.py +36 -18
  19. syllable_sdk/models/__init__.py +0 -9
  20. syllable_sdk/models/apierror.py +14 -30
  21. syllable_sdk/models/httpvalidationerror.py +6 -11
  22. syllable_sdk/numbers.py +110 -52
  23. syllable_sdk/organizations.py +138 -50
  24. syllable_sdk/permissions.py +32 -10
  25. syllable_sdk/prompts.py +248 -94
  26. syllable_sdk/roles.py +180 -74
  27. syllable_sdk/services.py +182 -72
  28. syllable_sdk/session_debug.py +108 -42
  29. syllable_sdk/session_labels.py +108 -46
  30. syllable_sdk/sessions.py +140 -58
  31. syllable_sdk/takeouts.py +98 -34
  32. syllable_sdk/targets.py +184 -74
  33. syllable_sdk/test.py +36 -14
  34. syllable_sdk/tools.py +180 -74
  35. syllable_sdk/transcript.py +38 -16
  36. syllable_sdk/twilio.py +108 -42
  37. syllable_sdk/users.py +246 -96
  38. syllable_sdk/utils/__init__.py +0 -3
  39. syllable_sdk/utils/serializers.py +4 -20
  40. syllable_sdk/v1.py +246 -96
  41. syllable_sdk/workflows.py +290 -114
  42. {syllable_sdk-0.35.30.dist-info → syllable_sdk-0.35.32.dist-info}/METADATA +24 -44
  43. {syllable_sdk-0.35.30.dist-info → syllable_sdk-0.35.32.dist-info}/RECORD +44 -47
  44. syllable_sdk/models/no_response_error.py +0 -13
  45. syllable_sdk/models/responsevalidationerror.py +0 -25
  46. syllable_sdk/models/syllablesdkerror.py +0 -26
  47. {syllable_sdk-0.35.30.dist-info → syllable_sdk-0.35.32.dist-info}/WHEEL +0 -0
@@ -109,22 +109,33 @@ 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_response(
113
- models.ListResponseInsightToolOutput, http_res
112
+ return utils.unmarshal_json(
113
+ http_res.text, models.ListResponseInsightToolOutput
114
114
  )
115
115
  if utils.match_response(http_res, "422", "application/json"):
116
- response_data = utils.unmarshal_json_response(
117
- models.HTTPValidationErrorData, http_res
116
+ response_data = utils.unmarshal_json(
117
+ http_res.text, models.HTTPValidationErrorData
118
118
  )
119
- raise models.HTTPValidationError(response_data, http_res)
119
+ raise models.HTTPValidationError(data=response_data)
120
120
  if utils.match_response(http_res, "4XX", "*"):
121
121
  http_res_text = utils.stream_to_text(http_res)
122
- raise models.APIError("API error occurred", http_res, http_res_text)
122
+ raise models.APIError(
123
+ "API error occurred", http_res.status_code, http_res_text, http_res
124
+ )
123
125
  if utils.match_response(http_res, "5XX", "*"):
124
126
  http_res_text = utils.stream_to_text(http_res)
125
- raise models.APIError("API error occurred", http_res, http_res_text)
127
+ raise models.APIError(
128
+ "API error occurred", http_res.status_code, http_res_text, http_res
129
+ )
126
130
 
127
- raise models.APIError("Unexpected response received", http_res)
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
139
 
129
140
  async def list_async(
130
141
  self,
@@ -224,22 +235,33 @@ class InsightsTools(BaseSDK):
224
235
 
225
236
  response_data: Any = None
226
237
  if utils.match_response(http_res, "200", "application/json"):
227
- return utils.unmarshal_json_response(
228
- models.ListResponseInsightToolOutput, http_res
238
+ return utils.unmarshal_json(
239
+ http_res.text, models.ListResponseInsightToolOutput
229
240
  )
230
241
  if utils.match_response(http_res, "422", "application/json"):
231
- response_data = utils.unmarshal_json_response(
232
- models.HTTPValidationErrorData, http_res
242
+ response_data = utils.unmarshal_json(
243
+ http_res.text, models.HTTPValidationErrorData
233
244
  )
234
- raise models.HTTPValidationError(response_data, http_res)
245
+ raise models.HTTPValidationError(data=response_data)
235
246
  if utils.match_response(http_res, "4XX", "*"):
236
247
  http_res_text = await utils.stream_to_text_async(http_res)
237
- raise models.APIError("API error occurred", http_res, http_res_text)
248
+ raise models.APIError(
249
+ "API error occurred", http_res.status_code, http_res_text, http_res
250
+ )
238
251
  if utils.match_response(http_res, "5XX", "*"):
239
252
  http_res_text = await utils.stream_to_text_async(http_res)
240
- raise models.APIError("API error occurred", http_res, http_res_text)
253
+ raise models.APIError(
254
+ "API error occurred", http_res.status_code, http_res_text, http_res
255
+ )
241
256
 
242
- raise models.APIError("Unexpected response received", http_res)
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
265
 
244
266
  def create(
245
267
  self,
@@ -318,20 +340,31 @@ class InsightsTools(BaseSDK):
318
340
 
319
341
  response_data: Any = None
320
342
  if utils.match_response(http_res, "200", "application/json"):
321
- return utils.unmarshal_json_response(models.InsightToolOutput, http_res)
343
+ return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
322
344
  if utils.match_response(http_res, "422", "application/json"):
323
- response_data = utils.unmarshal_json_response(
324
- models.HTTPValidationErrorData, http_res
345
+ response_data = utils.unmarshal_json(
346
+ http_res.text, models.HTTPValidationErrorData
325
347
  )
326
- raise models.HTTPValidationError(response_data, http_res)
348
+ raise models.HTTPValidationError(data=response_data)
327
349
  if utils.match_response(http_res, ["400", "4XX"], "*"):
328
350
  http_res_text = utils.stream_to_text(http_res)
329
- raise models.APIError("API error occurred", http_res, http_res_text)
351
+ raise models.APIError(
352
+ "API error occurred", http_res.status_code, http_res_text, http_res
353
+ )
330
354
  if utils.match_response(http_res, ["500", "5XX"], "*"):
331
355
  http_res_text = utils.stream_to_text(http_res)
332
- raise models.APIError("API error occurred", http_res, http_res_text)
356
+ raise models.APIError(
357
+ "API error occurred", http_res.status_code, http_res_text, http_res
358
+ )
333
359
 
334
- raise models.APIError("Unexpected response received", http_res)
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
368
 
336
369
  async def create_async(
337
370
  self,
@@ -410,20 +443,31 @@ class InsightsTools(BaseSDK):
410
443
 
411
444
  response_data: Any = None
412
445
  if utils.match_response(http_res, "200", "application/json"):
413
- return utils.unmarshal_json_response(models.InsightToolOutput, http_res)
446
+ return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
414
447
  if utils.match_response(http_res, "422", "application/json"):
415
- response_data = utils.unmarshal_json_response(
416
- models.HTTPValidationErrorData, http_res
448
+ response_data = utils.unmarshal_json(
449
+ http_res.text, models.HTTPValidationErrorData
417
450
  )
418
- raise models.HTTPValidationError(response_data, http_res)
451
+ raise models.HTTPValidationError(data=response_data)
419
452
  if utils.match_response(http_res, ["400", "4XX"], "*"):
420
453
  http_res_text = await utils.stream_to_text_async(http_res)
421
- raise models.APIError("API error occurred", http_res, http_res_text)
454
+ raise models.APIError(
455
+ "API error occurred", http_res.status_code, http_res_text, http_res
456
+ )
422
457
  if utils.match_response(http_res, ["500", "5XX"], "*"):
423
458
  http_res_text = await utils.stream_to_text_async(http_res)
424
- raise models.APIError("API error occurred", http_res, http_res_text)
459
+ raise models.APIError(
460
+ "API error occurred", http_res.status_code, http_res_text, http_res
461
+ )
425
462
 
426
- raise models.APIError("Unexpected response received", http_res)
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
471
 
428
472
  def get_by_id(
429
473
  self,
@@ -499,20 +543,31 @@ class InsightsTools(BaseSDK):
499
543
 
500
544
  response_data: Any = None
501
545
  if utils.match_response(http_res, "200", "application/json"):
502
- return utils.unmarshal_json_response(models.InsightToolOutput, http_res)
546
+ return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
503
547
  if utils.match_response(http_res, "422", "application/json"):
504
- response_data = utils.unmarshal_json_response(
505
- models.HTTPValidationErrorData, http_res
548
+ response_data = utils.unmarshal_json(
549
+ http_res.text, models.HTTPValidationErrorData
506
550
  )
507
- raise models.HTTPValidationError(response_data, http_res)
551
+ raise models.HTTPValidationError(data=response_data)
508
552
  if utils.match_response(http_res, "4XX", "*"):
509
553
  http_res_text = utils.stream_to_text(http_res)
510
- raise models.APIError("API error occurred", http_res, http_res_text)
554
+ raise models.APIError(
555
+ "API error occurred", http_res.status_code, http_res_text, http_res
556
+ )
511
557
  if utils.match_response(http_res, "5XX", "*"):
512
558
  http_res_text = utils.stream_to_text(http_res)
513
- raise models.APIError("API error occurred", http_res, http_res_text)
559
+ raise models.APIError(
560
+ "API error occurred", http_res.status_code, http_res_text, http_res
561
+ )
514
562
 
515
- raise models.APIError("Unexpected response received", http_res)
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
571
 
517
572
  async def get_by_id_async(
518
573
  self,
@@ -588,20 +643,31 @@ class InsightsTools(BaseSDK):
588
643
 
589
644
  response_data: Any = None
590
645
  if utils.match_response(http_res, "200", "application/json"):
591
- return utils.unmarshal_json_response(models.InsightToolOutput, http_res)
646
+ return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
592
647
  if utils.match_response(http_res, "422", "application/json"):
593
- response_data = utils.unmarshal_json_response(
594
- models.HTTPValidationErrorData, http_res
648
+ response_data = utils.unmarshal_json(
649
+ http_res.text, models.HTTPValidationErrorData
595
650
  )
596
- raise models.HTTPValidationError(response_data, http_res)
651
+ raise models.HTTPValidationError(data=response_data)
597
652
  if utils.match_response(http_res, "4XX", "*"):
598
653
  http_res_text = await utils.stream_to_text_async(http_res)
599
- raise models.APIError("API error occurred", http_res, http_res_text)
654
+ raise models.APIError(
655
+ "API error occurred", http_res.status_code, http_res_text, http_res
656
+ )
600
657
  if utils.match_response(http_res, "5XX", "*"):
601
658
  http_res_text = await utils.stream_to_text_async(http_res)
602
- raise models.APIError("API error occurred", http_res, http_res_text)
659
+ raise models.APIError(
660
+ "API error occurred", http_res.status_code, http_res_text, http_res
661
+ )
603
662
 
604
- raise models.APIError("Unexpected response received", http_res)
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
671
 
606
672
  def delete(
607
673
  self,
@@ -677,20 +743,31 @@ class InsightsTools(BaseSDK):
677
743
 
678
744
  response_data: Any = None
679
745
  if utils.match_response(http_res, "200", "application/json"):
680
- return utils.unmarshal_json_response(Any, http_res)
746
+ return utils.unmarshal_json(http_res.text, Any)
681
747
  if utils.match_response(http_res, "422", "application/json"):
682
- response_data = utils.unmarshal_json_response(
683
- models.HTTPValidationErrorData, http_res
748
+ response_data = utils.unmarshal_json(
749
+ http_res.text, models.HTTPValidationErrorData
684
750
  )
685
- raise models.HTTPValidationError(response_data, http_res)
751
+ raise models.HTTPValidationError(data=response_data)
686
752
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
687
753
  http_res_text = utils.stream_to_text(http_res)
688
- raise models.APIError("API error occurred", http_res, http_res_text)
754
+ raise models.APIError(
755
+ "API error occurred", http_res.status_code, http_res_text, http_res
756
+ )
689
757
  if utils.match_response(http_res, ["500", "5XX"], "*"):
690
758
  http_res_text = utils.stream_to_text(http_res)
691
- raise models.APIError("API error occurred", http_res, http_res_text)
759
+ raise models.APIError(
760
+ "API error occurred", http_res.status_code, http_res_text, http_res
761
+ )
692
762
 
693
- raise models.APIError("Unexpected response received", http_res)
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
771
 
695
772
  async def delete_async(
696
773
  self,
@@ -766,20 +843,31 @@ class InsightsTools(BaseSDK):
766
843
 
767
844
  response_data: Any = None
768
845
  if utils.match_response(http_res, "200", "application/json"):
769
- return utils.unmarshal_json_response(Any, http_res)
846
+ return utils.unmarshal_json(http_res.text, Any)
770
847
  if utils.match_response(http_res, "422", "application/json"):
771
- response_data = utils.unmarshal_json_response(
772
- models.HTTPValidationErrorData, http_res
848
+ response_data = utils.unmarshal_json(
849
+ http_res.text, models.HTTPValidationErrorData
773
850
  )
774
- raise models.HTTPValidationError(response_data, http_res)
851
+ raise models.HTTPValidationError(data=response_data)
775
852
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
776
853
  http_res_text = await utils.stream_to_text_async(http_res)
777
- raise models.APIError("API error occurred", http_res, http_res_text)
854
+ raise models.APIError(
855
+ "API error occurred", http_res.status_code, http_res_text, http_res
856
+ )
778
857
  if utils.match_response(http_res, ["500", "5XX"], "*"):
779
858
  http_res_text = await utils.stream_to_text_async(http_res)
780
- raise models.APIError("API error occurred", http_res, http_res_text)
859
+ raise models.APIError(
860
+ "API error occurred", http_res.status_code, http_res_text, http_res
861
+ )
781
862
 
782
- raise models.APIError("Unexpected response received", http_res)
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
871
 
784
872
  def update(
785
873
  self,
@@ -869,20 +957,31 @@ class InsightsTools(BaseSDK):
869
957
 
870
958
  response_data: Any = None
871
959
  if utils.match_response(http_res, "200", "application/json"):
872
- return utils.unmarshal_json_response(models.InsightToolOutput, http_res)
960
+ return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
873
961
  if utils.match_response(http_res, "422", "application/json"):
874
- response_data = utils.unmarshal_json_response(
875
- models.HTTPValidationErrorData, http_res
962
+ response_data = utils.unmarshal_json(
963
+ http_res.text, models.HTTPValidationErrorData
876
964
  )
877
- raise models.HTTPValidationError(response_data, http_res)
965
+ raise models.HTTPValidationError(data=response_data)
878
966
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
879
967
  http_res_text = utils.stream_to_text(http_res)
880
- raise models.APIError("API error occurred", http_res, http_res_text)
968
+ raise models.APIError(
969
+ "API error occurred", http_res.status_code, http_res_text, http_res
970
+ )
881
971
  if utils.match_response(http_res, ["500", "5XX"], "*"):
882
972
  http_res_text = utils.stream_to_text(http_res)
883
- raise models.APIError("API error occurred", http_res, http_res_text)
973
+ raise models.APIError(
974
+ "API error occurred", http_res.status_code, http_res_text, http_res
975
+ )
884
976
 
885
- raise models.APIError("Unexpected response received", http_res)
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
985
 
887
986
  async def update_async(
888
987
  self,
@@ -972,20 +1071,31 @@ class InsightsTools(BaseSDK):
972
1071
 
973
1072
  response_data: Any = None
974
1073
  if utils.match_response(http_res, "200", "application/json"):
975
- return utils.unmarshal_json_response(models.InsightToolOutput, http_res)
1074
+ return utils.unmarshal_json(http_res.text, models.InsightToolOutput)
976
1075
  if utils.match_response(http_res, "422", "application/json"):
977
- response_data = utils.unmarshal_json_response(
978
- models.HTTPValidationErrorData, http_res
1076
+ response_data = utils.unmarshal_json(
1077
+ http_res.text, models.HTTPValidationErrorData
979
1078
  )
980
- raise models.HTTPValidationError(response_data, http_res)
1079
+ raise models.HTTPValidationError(data=response_data)
981
1080
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
982
1081
  http_res_text = await utils.stream_to_text_async(http_res)
983
- raise models.APIError("API error occurred", http_res, http_res_text)
1082
+ raise models.APIError(
1083
+ "API error occurred", http_res.status_code, http_res_text, http_res
1084
+ )
984
1085
  if utils.match_response(http_res, ["500", "5XX"], "*"):
985
1086
  http_res_text = await utils.stream_to_text_async(http_res)
986
- raise models.APIError("API error occurred", http_res, http_res_text)
1087
+ raise models.APIError(
1088
+ "API error occurred", http_res.status_code, http_res_text, http_res
1089
+ )
987
1090
 
988
- raise models.APIError("Unexpected response received", http_res)
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
1099
 
990
1100
  def insights_tool_test(
991
1101
  self,
@@ -1066,20 +1176,31 @@ class InsightsTools(BaseSDK):
1066
1176
 
1067
1177
  response_data: Any = None
1068
1178
  if utils.match_response(http_res, "200", "application/json"):
1069
- return utils.unmarshal_json_response(Any, http_res)
1179
+ return utils.unmarshal_json(http_res.text, Any)
1070
1180
  if utils.match_response(http_res, "422", "application/json"):
1071
- response_data = utils.unmarshal_json_response(
1072
- models.HTTPValidationErrorData, http_res
1181
+ response_data = utils.unmarshal_json(
1182
+ http_res.text, models.HTTPValidationErrorData
1073
1183
  )
1074
- raise models.HTTPValidationError(response_data, http_res)
1184
+ raise models.HTTPValidationError(data=response_data)
1075
1185
  if utils.match_response(http_res, ["400", "404", "4XX"], "*"):
1076
1186
  http_res_text = utils.stream_to_text(http_res)
1077
- raise models.APIError("API error occurred", http_res, http_res_text)
1187
+ raise models.APIError(
1188
+ "API error occurred", http_res.status_code, http_res_text, http_res
1189
+ )
1078
1190
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1079
1191
  http_res_text = utils.stream_to_text(http_res)
1080
- raise models.APIError("API error occurred", http_res, http_res_text)
1192
+ raise models.APIError(
1193
+ "API error occurred", http_res.status_code, http_res_text, http_res
1194
+ )
1081
1195
 
1082
- raise models.APIError("Unexpected response received", http_res)
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
1204
 
1084
1205
  async def insights_tool_test_async(
1085
1206
  self,
@@ -1160,20 +1281,31 @@ class InsightsTools(BaseSDK):
1160
1281
 
1161
1282
  response_data: Any = None
1162
1283
  if utils.match_response(http_res, "200", "application/json"):
1163
- return utils.unmarshal_json_response(Any, http_res)
1284
+ return utils.unmarshal_json(http_res.text, Any)
1164
1285
  if utils.match_response(http_res, "422", "application/json"):
1165
- response_data = utils.unmarshal_json_response(
1166
- models.HTTPValidationErrorData, http_res
1286
+ response_data = utils.unmarshal_json(
1287
+ http_res.text, models.HTTPValidationErrorData
1167
1288
  )
1168
- raise models.HTTPValidationError(response_data, http_res)
1289
+ raise models.HTTPValidationError(data=response_data)
1169
1290
  if utils.match_response(http_res, ["400", "404", "4XX"], "*"):
1170
1291
  http_res_text = await utils.stream_to_text_async(http_res)
1171
- raise models.APIError("API error occurred", http_res, http_res_text)
1292
+ raise models.APIError(
1293
+ "API error occurred", http_res.status_code, http_res_text, http_res
1294
+ )
1172
1295
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1173
1296
  http_res_text = await utils.stream_to_text_async(http_res)
1174
- raise models.APIError("API error occurred", http_res, http_res_text)
1297
+ raise models.APIError(
1298
+ "API error occurred", http_res.status_code, http_res_text, http_res
1299
+ )
1175
1300
 
1176
- raise models.APIError("Unexpected response received", http_res)
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
1309
 
1178
1310
  def insight_tool_get_definitions(
1179
1311
  self,
@@ -1241,17 +1373,28 @@ class InsightsTools(BaseSDK):
1241
1373
  )
1242
1374
 
1243
1375
  if utils.match_response(http_res, "200", "application/json"):
1244
- return utils.unmarshal_json_response(
1245
- List[models.InsightToolDefinition], http_res
1376
+ return utils.unmarshal_json(
1377
+ http_res.text, List[models.InsightToolDefinition]
1246
1378
  )
1247
1379
  if utils.match_response(http_res, "4XX", "*"):
1248
1380
  http_res_text = utils.stream_to_text(http_res)
1249
- raise models.APIError("API error occurred", http_res, http_res_text)
1381
+ raise models.APIError(
1382
+ "API error occurred", http_res.status_code, http_res_text, http_res
1383
+ )
1250
1384
  if utils.match_response(http_res, "5XX", "*"):
1251
1385
  http_res_text = utils.stream_to_text(http_res)
1252
- raise models.APIError("API error occurred", http_res, http_res_text)
1386
+ raise models.APIError(
1387
+ "API error occurred", http_res.status_code, http_res_text, http_res
1388
+ )
1253
1389
 
1254
- raise models.APIError("Unexpected response received", http_res)
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
+ )
1255
1398
 
1256
1399
  async def insight_tool_get_definitions_async(
1257
1400
  self,
@@ -1319,14 +1462,25 @@ class InsightsTools(BaseSDK):
1319
1462
  )
1320
1463
 
1321
1464
  if utils.match_response(http_res, "200", "application/json"):
1322
- return utils.unmarshal_json_response(
1323
- List[models.InsightToolDefinition], http_res
1465
+ return utils.unmarshal_json(
1466
+ http_res.text, List[models.InsightToolDefinition]
1324
1467
  )
1325
1468
  if utils.match_response(http_res, "4XX", "*"):
1326
1469
  http_res_text = await utils.stream_to_text_async(http_res)
1327
- raise models.APIError("API error occurred", http_res, http_res_text)
1470
+ raise models.APIError(
1471
+ "API error occurred", http_res.status_code, http_res_text, http_res
1472
+ )
1328
1473
  if utils.match_response(http_res, "5XX", "*"):
1329
1474
  http_res_text = await utils.stream_to_text_async(http_res)
1330
- raise models.APIError("API error occurred", http_res, http_res_text)
1475
+ raise models.APIError(
1476
+ "API error occurred", http_res.status_code, http_res_text, http_res
1477
+ )
1331
1478
 
1332
- raise models.APIError("Unexpected response received", http_res)
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
+ )