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
syllable_sdk/workflows.py CHANGED
@@ -1,7 +1,7 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from syllable_sdk import models, utils
4
+ from syllable_sdk import errors, models, utils
5
5
  from syllable_sdk._hooks import HookContext
6
6
  from syllable_sdk.types import BaseModel, OptionalNullable, UNSET
7
7
  from syllable_sdk.utils import get_security_from_env
@@ -109,33 +109,22 @@ class Workflows(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.ListResponseInsightWorkflowOutput
112
+ return utils.unmarshal_json_response(
113
+ models.ListResponseInsightWorkflowOutput, 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 Workflows(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.ListResponseInsightWorkflowOutput
227
+ return utils.unmarshal_json_response(
228
+ models.ListResponseInsightWorkflowOutput, 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,
@@ -342,31 +320,20 @@ class Workflows(BaseSDK):
342
320
 
343
321
  response_data: Any = None
344
322
  if utils.match_response(http_res, "200", "application/json"):
345
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
323
+ return utils.unmarshal_json_response(models.InsightWorkflowOutput, http_res)
346
324
  if utils.match_response(http_res, "422", "application/json"):
347
- response_data = utils.unmarshal_json(
348
- http_res.text, models.HTTPValidationErrorData
325
+ response_data = utils.unmarshal_json_response(
326
+ errors.HTTPValidationErrorData, http_res
349
327
  )
350
- raise models.HTTPValidationError(data=response_data)
328
+ raise errors.HTTPValidationError(response_data, http_res)
351
329
  if utils.match_response(http_res, "4XX", "*"):
352
330
  http_res_text = utils.stream_to_text(http_res)
353
- raise models.APIError(
354
- "API error occurred", http_res.status_code, http_res_text, http_res
355
- )
331
+ raise errors.APIError("API error occurred", http_res, http_res_text)
356
332
  if utils.match_response(http_res, "5XX", "*"):
357
333
  http_res_text = utils.stream_to_text(http_res)
358
- raise models.APIError(
359
- "API error occurred", http_res.status_code, http_res_text, http_res
360
- )
334
+ raise errors.APIError("API error occurred", http_res, http_res_text)
361
335
 
362
- content_type = http_res.headers.get("Content-Type")
363
- http_res_text = utils.stream_to_text(http_res)
364
- raise models.APIError(
365
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
366
- http_res.status_code,
367
- http_res_text,
368
- http_res,
369
- )
336
+ raise errors.APIError("Unexpected response received", http_res)
370
337
 
371
338
  async def create_async(
372
339
  self,
@@ -447,31 +414,20 @@ class Workflows(BaseSDK):
447
414
 
448
415
  response_data: Any = None
449
416
  if utils.match_response(http_res, "200", "application/json"):
450
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
417
+ return utils.unmarshal_json_response(models.InsightWorkflowOutput, http_res)
451
418
  if utils.match_response(http_res, "422", "application/json"):
452
- response_data = utils.unmarshal_json(
453
- http_res.text, models.HTTPValidationErrorData
419
+ response_data = utils.unmarshal_json_response(
420
+ errors.HTTPValidationErrorData, http_res
454
421
  )
455
- raise models.HTTPValidationError(data=response_data)
422
+ raise errors.HTTPValidationError(response_data, http_res)
456
423
  if utils.match_response(http_res, "4XX", "*"):
457
424
  http_res_text = await utils.stream_to_text_async(http_res)
458
- raise models.APIError(
459
- "API error occurred", http_res.status_code, http_res_text, http_res
460
- )
425
+ raise errors.APIError("API error occurred", http_res, http_res_text)
461
426
  if utils.match_response(http_res, "5XX", "*"):
462
427
  http_res_text = await utils.stream_to_text_async(http_res)
463
- raise models.APIError(
464
- "API error occurred", http_res.status_code, http_res_text, http_res
465
- )
428
+ raise errors.APIError("API error occurred", http_res, http_res_text)
466
429
 
467
- content_type = http_res.headers.get("Content-Type")
468
- http_res_text = await utils.stream_to_text_async(http_res)
469
- raise models.APIError(
470
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
471
- http_res.status_code,
472
- http_res_text,
473
- http_res,
474
- )
430
+ raise errors.APIError("Unexpected response received", http_res)
475
431
 
476
432
  def get_by_id(
477
433
  self,
@@ -547,31 +503,20 @@ class Workflows(BaseSDK):
547
503
 
548
504
  response_data: Any = None
549
505
  if utils.match_response(http_res, "200", "application/json"):
550
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
506
+ return utils.unmarshal_json_response(models.InsightWorkflowOutput, http_res)
551
507
  if utils.match_response(http_res, "422", "application/json"):
552
- response_data = utils.unmarshal_json(
553
- http_res.text, models.HTTPValidationErrorData
508
+ response_data = utils.unmarshal_json_response(
509
+ errors.HTTPValidationErrorData, http_res
554
510
  )
555
- raise models.HTTPValidationError(data=response_data)
511
+ raise errors.HTTPValidationError(response_data, http_res)
556
512
  if utils.match_response(http_res, "4XX", "*"):
557
513
  http_res_text = utils.stream_to_text(http_res)
558
- raise models.APIError(
559
- "API error occurred", http_res.status_code, http_res_text, http_res
560
- )
514
+ raise errors.APIError("API error occurred", http_res, http_res_text)
561
515
  if utils.match_response(http_res, "5XX", "*"):
562
516
  http_res_text = utils.stream_to_text(http_res)
563
- raise models.APIError(
564
- "API error occurred", http_res.status_code, http_res_text, http_res
565
- )
517
+ raise errors.APIError("API error occurred", http_res, http_res_text)
566
518
 
567
- content_type = http_res.headers.get("Content-Type")
568
- http_res_text = utils.stream_to_text(http_res)
569
- raise models.APIError(
570
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
571
- http_res.status_code,
572
- http_res_text,
573
- http_res,
574
- )
519
+ raise errors.APIError("Unexpected response received", http_res)
575
520
 
576
521
  async def get_by_id_async(
577
522
  self,
@@ -647,31 +592,20 @@ class Workflows(BaseSDK):
647
592
 
648
593
  response_data: Any = None
649
594
  if utils.match_response(http_res, "200", "application/json"):
650
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
595
+ return utils.unmarshal_json_response(models.InsightWorkflowOutput, http_res)
651
596
  if utils.match_response(http_res, "422", "application/json"):
652
- response_data = utils.unmarshal_json(
653
- http_res.text, models.HTTPValidationErrorData
597
+ response_data = utils.unmarshal_json_response(
598
+ errors.HTTPValidationErrorData, http_res
654
599
  )
655
- raise models.HTTPValidationError(data=response_data)
600
+ raise errors.HTTPValidationError(response_data, http_res)
656
601
  if utils.match_response(http_res, "4XX", "*"):
657
602
  http_res_text = await utils.stream_to_text_async(http_res)
658
- raise models.APIError(
659
- "API error occurred", http_res.status_code, http_res_text, http_res
660
- )
603
+ raise errors.APIError("API error occurred", http_res, http_res_text)
661
604
  if utils.match_response(http_res, "5XX", "*"):
662
605
  http_res_text = await utils.stream_to_text_async(http_res)
663
- raise models.APIError(
664
- "API error occurred", http_res.status_code, http_res_text, http_res
665
- )
606
+ raise errors.APIError("API error occurred", http_res, http_res_text)
666
607
 
667
- content_type = http_res.headers.get("Content-Type")
668
- http_res_text = await utils.stream_to_text_async(http_res)
669
- raise models.APIError(
670
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
671
- http_res.status_code,
672
- http_res_text,
673
- http_res,
674
- )
608
+ raise errors.APIError("Unexpected response received", http_res)
675
609
 
676
610
  def update(
677
611
  self,
@@ -761,31 +695,20 @@ class Workflows(BaseSDK):
761
695
 
762
696
  response_data: Any = None
763
697
  if utils.match_response(http_res, "200", "application/json"):
764
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
698
+ return utils.unmarshal_json_response(models.InsightWorkflowOutput, http_res)
765
699
  if utils.match_response(http_res, "422", "application/json"):
766
- response_data = utils.unmarshal_json(
767
- http_res.text, models.HTTPValidationErrorData
700
+ response_data = utils.unmarshal_json_response(
701
+ errors.HTTPValidationErrorData, http_res
768
702
  )
769
- raise models.HTTPValidationError(data=response_data)
703
+ raise errors.HTTPValidationError(response_data, http_res)
770
704
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
771
705
  http_res_text = utils.stream_to_text(http_res)
772
- raise models.APIError(
773
- "API error occurred", http_res.status_code, http_res_text, http_res
774
- )
706
+ raise errors.APIError("API error occurred", http_res, http_res_text)
775
707
  if utils.match_response(http_res, ["500", "5XX"], "*"):
776
708
  http_res_text = utils.stream_to_text(http_res)
777
- raise models.APIError(
778
- "API error occurred", http_res.status_code, http_res_text, http_res
779
- )
709
+ raise errors.APIError("API error occurred", http_res, http_res_text)
780
710
 
781
- content_type = http_res.headers.get("Content-Type")
782
- http_res_text = utils.stream_to_text(http_res)
783
- raise models.APIError(
784
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
785
- http_res.status_code,
786
- http_res_text,
787
- http_res,
788
- )
711
+ raise errors.APIError("Unexpected response received", http_res)
789
712
 
790
713
  async def update_async(
791
714
  self,
@@ -875,31 +798,20 @@ class Workflows(BaseSDK):
875
798
 
876
799
  response_data: Any = None
877
800
  if utils.match_response(http_res, "200", "application/json"):
878
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
801
+ return utils.unmarshal_json_response(models.InsightWorkflowOutput, http_res)
879
802
  if utils.match_response(http_res, "422", "application/json"):
880
- response_data = utils.unmarshal_json(
881
- http_res.text, models.HTTPValidationErrorData
803
+ response_data = utils.unmarshal_json_response(
804
+ errors.HTTPValidationErrorData, http_res
882
805
  )
883
- raise models.HTTPValidationError(data=response_data)
806
+ raise errors.HTTPValidationError(response_data, http_res)
884
807
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
885
808
  http_res_text = await utils.stream_to_text_async(http_res)
886
- raise models.APIError(
887
- "API error occurred", http_res.status_code, http_res_text, http_res
888
- )
809
+ raise errors.APIError("API error occurred", http_res, http_res_text)
889
810
  if utils.match_response(http_res, ["500", "5XX"], "*"):
890
811
  http_res_text = await utils.stream_to_text_async(http_res)
891
- raise models.APIError(
892
- "API error occurred", http_res.status_code, http_res_text, http_res
893
- )
812
+ raise errors.APIError("API error occurred", http_res, http_res_text)
894
813
 
895
- content_type = http_res.headers.get("Content-Type")
896
- http_res_text = await utils.stream_to_text_async(http_res)
897
- raise models.APIError(
898
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
899
- http_res.status_code,
900
- http_res_text,
901
- http_res,
902
- )
814
+ raise errors.APIError("Unexpected response received", http_res)
903
815
 
904
816
  def delete(
905
817
  self,
@@ -975,31 +887,20 @@ class Workflows(BaseSDK):
975
887
 
976
888
  response_data: Any = None
977
889
  if utils.match_response(http_res, "200", "application/json"):
978
- return utils.unmarshal_json(http_res.text, Any)
890
+ return utils.unmarshal_json_response(Any, http_res)
979
891
  if utils.match_response(http_res, "422", "application/json"):
980
- response_data = utils.unmarshal_json(
981
- http_res.text, models.HTTPValidationErrorData
892
+ response_data = utils.unmarshal_json_response(
893
+ errors.HTTPValidationErrorData, http_res
982
894
  )
983
- raise models.HTTPValidationError(data=response_data)
895
+ raise errors.HTTPValidationError(response_data, http_res)
984
896
  if utils.match_response(http_res, ["400", "404", "4XX"], "*"):
985
897
  http_res_text = utils.stream_to_text(http_res)
986
- raise models.APIError(
987
- "API error occurred", http_res.status_code, http_res_text, http_res
988
- )
898
+ raise errors.APIError("API error occurred", http_res, http_res_text)
989
899
  if utils.match_response(http_res, ["500", "5XX"], "*"):
990
900
  http_res_text = utils.stream_to_text(http_res)
991
- raise models.APIError(
992
- "API error occurred", http_res.status_code, http_res_text, http_res
993
- )
901
+ raise errors.APIError("API error occurred", http_res, http_res_text)
994
902
 
995
- content_type = http_res.headers.get("Content-Type")
996
- http_res_text = utils.stream_to_text(http_res)
997
- raise models.APIError(
998
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
999
- http_res.status_code,
1000
- http_res_text,
1001
- http_res,
1002
- )
903
+ raise errors.APIError("Unexpected response received", http_res)
1003
904
 
1004
905
  async def delete_async(
1005
906
  self,
@@ -1075,31 +976,20 @@ class Workflows(BaseSDK):
1075
976
 
1076
977
  response_data: Any = None
1077
978
  if utils.match_response(http_res, "200", "application/json"):
1078
- return utils.unmarshal_json(http_res.text, Any)
979
+ return utils.unmarshal_json_response(Any, http_res)
1079
980
  if utils.match_response(http_res, "422", "application/json"):
1080
- response_data = utils.unmarshal_json(
1081
- http_res.text, models.HTTPValidationErrorData
981
+ response_data = utils.unmarshal_json_response(
982
+ errors.HTTPValidationErrorData, http_res
1082
983
  )
1083
- raise models.HTTPValidationError(data=response_data)
984
+ raise errors.HTTPValidationError(response_data, http_res)
1084
985
  if utils.match_response(http_res, ["400", "404", "4XX"], "*"):
1085
986
  http_res_text = await utils.stream_to_text_async(http_res)
1086
- raise models.APIError(
1087
- "API error occurred", http_res.status_code, http_res_text, http_res
1088
- )
987
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1089
988
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1090
989
  http_res_text = await utils.stream_to_text_async(http_res)
1091
- raise models.APIError(
1092
- "API error occurred", http_res.status_code, http_res_text, http_res
1093
- )
990
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1094
991
 
1095
- content_type = http_res.headers.get("Content-Type")
1096
- http_res_text = await utils.stream_to_text_async(http_res)
1097
- raise models.APIError(
1098
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1099
- http_res.status_code,
1100
- http_res_text,
1101
- http_res,
1102
- )
992
+ raise errors.APIError("Unexpected response received", http_res)
1103
993
 
1104
994
  def inactivate(
1105
995
  self,
@@ -1175,31 +1065,20 @@ class Workflows(BaseSDK):
1175
1065
 
1176
1066
  response_data: Any = None
1177
1067
  if utils.match_response(http_res, "200", "application/json"):
1178
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
1068
+ return utils.unmarshal_json_response(models.InsightWorkflowOutput, http_res)
1179
1069
  if utils.match_response(http_res, "422", "application/json"):
1180
- response_data = utils.unmarshal_json(
1181
- http_res.text, models.HTTPValidationErrorData
1070
+ response_data = utils.unmarshal_json_response(
1071
+ errors.HTTPValidationErrorData, http_res
1182
1072
  )
1183
- raise models.HTTPValidationError(data=response_data)
1073
+ raise errors.HTTPValidationError(response_data, http_res)
1184
1074
  if utils.match_response(http_res, ["404", "4XX"], "*"):
1185
1075
  http_res_text = utils.stream_to_text(http_res)
1186
- raise models.APIError(
1187
- "API error occurred", http_res.status_code, http_res_text, http_res
1188
- )
1076
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1189
1077
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1190
1078
  http_res_text = utils.stream_to_text(http_res)
1191
- raise models.APIError(
1192
- "API error occurred", http_res.status_code, http_res_text, http_res
1193
- )
1079
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1194
1080
 
1195
- content_type = http_res.headers.get("Content-Type")
1196
- 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
- )
1081
+ raise errors.APIError("Unexpected response received", http_res)
1203
1082
 
1204
1083
  async def inactivate_async(
1205
1084
  self,
@@ -1275,31 +1154,20 @@ class Workflows(BaseSDK):
1275
1154
 
1276
1155
  response_data: Any = None
1277
1156
  if utils.match_response(http_res, "200", "application/json"):
1278
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
1157
+ return utils.unmarshal_json_response(models.InsightWorkflowOutput, http_res)
1279
1158
  if utils.match_response(http_res, "422", "application/json"):
1280
- response_data = utils.unmarshal_json(
1281
- http_res.text, models.HTTPValidationErrorData
1159
+ response_data = utils.unmarshal_json_response(
1160
+ errors.HTTPValidationErrorData, http_res
1282
1161
  )
1283
- raise models.HTTPValidationError(data=response_data)
1162
+ raise errors.HTTPValidationError(response_data, http_res)
1284
1163
  if utils.match_response(http_res, ["404", "4XX"], "*"):
1285
1164
  http_res_text = await utils.stream_to_text_async(http_res)
1286
- raise models.APIError(
1287
- "API error occurred", http_res.status_code, http_res_text, http_res
1288
- )
1165
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1289
1166
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1290
1167
  http_res_text = await utils.stream_to_text_async(http_res)
1291
- raise models.APIError(
1292
- "API error occurred", http_res.status_code, http_res_text, http_res
1293
- )
1168
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1294
1169
 
1295
- content_type = http_res.headers.get("Content-Type")
1296
- http_res_text = await utils.stream_to_text_async(http_res)
1297
- raise models.APIError(
1298
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1299
- http_res.status_code,
1300
- http_res_text,
1301
- http_res,
1302
- )
1170
+ raise errors.APIError("Unexpected response received", http_res)
1303
1171
 
1304
1172
  def activate(
1305
1173
  self,
@@ -1389,31 +1257,20 @@ class Workflows(BaseSDK):
1389
1257
 
1390
1258
  response_data: Any = None
1391
1259
  if utils.match_response(http_res, "200", "application/json"):
1392
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
1260
+ return utils.unmarshal_json_response(models.InsightWorkflowOutput, http_res)
1393
1261
  if utils.match_response(http_res, "422", "application/json"):
1394
- response_data = utils.unmarshal_json(
1395
- http_res.text, models.HTTPValidationErrorData
1262
+ response_data = utils.unmarshal_json_response(
1263
+ errors.HTTPValidationErrorData, http_res
1396
1264
  )
1397
- raise models.HTTPValidationError(data=response_data)
1265
+ raise errors.HTTPValidationError(response_data, http_res)
1398
1266
  if utils.match_response(http_res, ["404", "4XX"], "*"):
1399
1267
  http_res_text = utils.stream_to_text(http_res)
1400
- raise models.APIError(
1401
- "API error occurred", http_res.status_code, http_res_text, http_res
1402
- )
1268
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1403
1269
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1404
1270
  http_res_text = utils.stream_to_text(http_res)
1405
- raise models.APIError(
1406
- "API error occurred", http_res.status_code, http_res_text, http_res
1407
- )
1271
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1408
1272
 
1409
- content_type = http_res.headers.get("Content-Type")
1410
- http_res_text = utils.stream_to_text(http_res)
1411
- raise models.APIError(
1412
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1413
- http_res.status_code,
1414
- http_res_text,
1415
- http_res,
1416
- )
1273
+ raise errors.APIError("Unexpected response received", http_res)
1417
1274
 
1418
1275
  async def activate_async(
1419
1276
  self,
@@ -1503,31 +1360,20 @@ class Workflows(BaseSDK):
1503
1360
 
1504
1361
  response_data: Any = None
1505
1362
  if utils.match_response(http_res, "200", "application/json"):
1506
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
1363
+ return utils.unmarshal_json_response(models.InsightWorkflowOutput, http_res)
1507
1364
  if utils.match_response(http_res, "422", "application/json"):
1508
- response_data = utils.unmarshal_json(
1509
- http_res.text, models.HTTPValidationErrorData
1365
+ response_data = utils.unmarshal_json_response(
1366
+ errors.HTTPValidationErrorData, http_res
1510
1367
  )
1511
- raise models.HTTPValidationError(data=response_data)
1368
+ raise errors.HTTPValidationError(response_data, http_res)
1512
1369
  if utils.match_response(http_res, ["404", "4XX"], "*"):
1513
1370
  http_res_text = await utils.stream_to_text_async(http_res)
1514
- raise models.APIError(
1515
- "API error occurred", http_res.status_code, http_res_text, http_res
1516
- )
1371
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1517
1372
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1518
1373
  http_res_text = await utils.stream_to_text_async(http_res)
1519
- raise models.APIError(
1520
- "API error occurred", http_res.status_code, http_res_text, http_res
1521
- )
1374
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1522
1375
 
1523
- content_type = http_res.headers.get("Content-Type")
1524
- http_res_text = await utils.stream_to_text_async(http_res)
1525
- raise models.APIError(
1526
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1527
- http_res.status_code,
1528
- http_res_text,
1529
- http_res,
1530
- )
1376
+ raise errors.APIError("Unexpected response received", http_res)
1531
1377
 
1532
1378
  def queue_work(
1533
1379
  self,
@@ -1609,31 +1455,20 @@ class Workflows(BaseSDK):
1609
1455
 
1610
1456
  response_data: Any = None
1611
1457
  if utils.match_response(http_res, "200", "application/json"):
1612
- return utils.unmarshal_json(http_res.text, Any)
1458
+ return utils.unmarshal_json_response(Any, http_res)
1613
1459
  if utils.match_response(http_res, "422", "application/json"):
1614
- response_data = utils.unmarshal_json(
1615
- http_res.text, models.HTTPValidationErrorData
1460
+ response_data = utils.unmarshal_json_response(
1461
+ errors.HTTPValidationErrorData, http_res
1616
1462
  )
1617
- raise models.HTTPValidationError(data=response_data)
1463
+ raise errors.HTTPValidationError(response_data, http_res)
1618
1464
  if utils.match_response(http_res, ["400", "404", "4XX"], "*"):
1619
1465
  http_res_text = utils.stream_to_text(http_res)
1620
- raise models.APIError(
1621
- "API error occurred", http_res.status_code, http_res_text, http_res
1622
- )
1466
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1623
1467
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1624
1468
  http_res_text = utils.stream_to_text(http_res)
1625
- raise models.APIError(
1626
- "API error occurred", http_res.status_code, http_res_text, http_res
1627
- )
1469
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1628
1470
 
1629
- content_type = http_res.headers.get("Content-Type")
1630
- http_res_text = utils.stream_to_text(http_res)
1631
- raise models.APIError(
1632
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1633
- http_res.status_code,
1634
- http_res_text,
1635
- http_res,
1636
- )
1471
+ raise errors.APIError("Unexpected response received", http_res)
1637
1472
 
1638
1473
  async def queue_work_async(
1639
1474
  self,
@@ -1715,28 +1550,17 @@ class Workflows(BaseSDK):
1715
1550
 
1716
1551
  response_data: Any = None
1717
1552
  if utils.match_response(http_res, "200", "application/json"):
1718
- return utils.unmarshal_json(http_res.text, Any)
1553
+ return utils.unmarshal_json_response(Any, http_res)
1719
1554
  if utils.match_response(http_res, "422", "application/json"):
1720
- response_data = utils.unmarshal_json(
1721
- http_res.text, models.HTTPValidationErrorData
1555
+ response_data = utils.unmarshal_json_response(
1556
+ errors.HTTPValidationErrorData, http_res
1722
1557
  )
1723
- raise models.HTTPValidationError(data=response_data)
1558
+ raise errors.HTTPValidationError(response_data, http_res)
1724
1559
  if utils.match_response(http_res, ["400", "404", "4XX"], "*"):
1725
1560
  http_res_text = await utils.stream_to_text_async(http_res)
1726
- raise models.APIError(
1727
- "API error occurred", http_res.status_code, http_res_text, http_res
1728
- )
1561
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1729
1562
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1730
1563
  http_res_text = await utils.stream_to_text_async(http_res)
1731
- raise models.APIError(
1732
- "API error occurred", http_res.status_code, http_res_text, http_res
1733
- )
1564
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1734
1565
 
1735
- content_type = http_res.headers.get("Content-Type")
1736
- http_res_text = await utils.stream_to_text_async(http_res)
1737
- raise models.APIError(
1738
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1739
- http_res.status_code,
1740
- http_res_text,
1741
- http_res,
1742
- )
1566
+ raise errors.APIError("Unexpected response received", http_res)