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
syllable_sdk/workflows.py CHANGED
@@ -1,10 +1,11 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from syllable_sdk import models, utils
4
+ from syllable_sdk import errors, models, utils
5
5
  from syllable_sdk._hooks import HookContext
6
6
  from syllable_sdk.types import 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 Workflows(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.ListResponseInsightWorkflowOutput
113
+ return unmarshal_json_response(
114
+ models.ListResponseInsightWorkflowOutput, 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 Workflows(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.ListResponseInsightWorkflowOutput
228
+ return unmarshal_json_response(
229
+ models.ListResponseInsightWorkflowOutput, 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,
@@ -342,31 +321,20 @@ class Workflows(BaseSDK):
342
321
 
343
322
  response_data: Any = None
344
323
  if utils.match_response(http_res, "200", "application/json"):
345
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
324
+ return unmarshal_json_response(models.InsightWorkflowOutput, http_res)
346
325
  if utils.match_response(http_res, "422", "application/json"):
347
- response_data = utils.unmarshal_json(
348
- http_res.text, models.HTTPValidationErrorData
326
+ response_data = unmarshal_json_response(
327
+ errors.HTTPValidationErrorData, http_res
349
328
  )
350
- raise models.HTTPValidationError(data=response_data)
329
+ raise errors.HTTPValidationError(response_data, http_res)
351
330
  if utils.match_response(http_res, "4XX", "*"):
352
331
  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
- )
332
+ raise errors.APIError("API error occurred", http_res, http_res_text)
356
333
  if utils.match_response(http_res, "5XX", "*"):
357
334
  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
- )
335
+ raise errors.APIError("API error occurred", http_res, http_res_text)
361
336
 
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
- )
337
+ raise errors.APIError("Unexpected response received", http_res)
370
338
 
371
339
  async def create_async(
372
340
  self,
@@ -447,31 +415,20 @@ class Workflows(BaseSDK):
447
415
 
448
416
  response_data: Any = None
449
417
  if utils.match_response(http_res, "200", "application/json"):
450
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
418
+ return unmarshal_json_response(models.InsightWorkflowOutput, http_res)
451
419
  if utils.match_response(http_res, "422", "application/json"):
452
- response_data = utils.unmarshal_json(
453
- http_res.text, models.HTTPValidationErrorData
420
+ response_data = unmarshal_json_response(
421
+ errors.HTTPValidationErrorData, http_res
454
422
  )
455
- raise models.HTTPValidationError(data=response_data)
423
+ raise errors.HTTPValidationError(response_data, http_res)
456
424
  if utils.match_response(http_res, "4XX", "*"):
457
425
  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
- )
426
+ raise errors.APIError("API error occurred", http_res, http_res_text)
461
427
  if utils.match_response(http_res, "5XX", "*"):
462
428
  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
- )
429
+ raise errors.APIError("API error occurred", http_res, http_res_text)
466
430
 
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
- )
431
+ raise errors.APIError("Unexpected response received", http_res)
475
432
 
476
433
  def get_by_id(
477
434
  self,
@@ -547,31 +504,20 @@ class Workflows(BaseSDK):
547
504
 
548
505
  response_data: Any = None
549
506
  if utils.match_response(http_res, "200", "application/json"):
550
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
507
+ return unmarshal_json_response(models.InsightWorkflowOutput, http_res)
551
508
  if utils.match_response(http_res, "422", "application/json"):
552
- response_data = utils.unmarshal_json(
553
- http_res.text, models.HTTPValidationErrorData
509
+ response_data = unmarshal_json_response(
510
+ errors.HTTPValidationErrorData, http_res
554
511
  )
555
- raise models.HTTPValidationError(data=response_data)
512
+ raise errors.HTTPValidationError(response_data, http_res)
556
513
  if utils.match_response(http_res, "4XX", "*"):
557
514
  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
- )
515
+ raise errors.APIError("API error occurred", http_res, http_res_text)
561
516
  if utils.match_response(http_res, "5XX", "*"):
562
517
  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
- )
518
+ raise errors.APIError("API error occurred", http_res, http_res_text)
566
519
 
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
- )
520
+ raise errors.APIError("Unexpected response received", http_res)
575
521
 
576
522
  async def get_by_id_async(
577
523
  self,
@@ -647,31 +593,20 @@ class Workflows(BaseSDK):
647
593
 
648
594
  response_data: Any = None
649
595
  if utils.match_response(http_res, "200", "application/json"):
650
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
596
+ return unmarshal_json_response(models.InsightWorkflowOutput, http_res)
651
597
  if utils.match_response(http_res, "422", "application/json"):
652
- response_data = utils.unmarshal_json(
653
- http_res.text, models.HTTPValidationErrorData
598
+ response_data = unmarshal_json_response(
599
+ errors.HTTPValidationErrorData, http_res
654
600
  )
655
- raise models.HTTPValidationError(data=response_data)
601
+ raise errors.HTTPValidationError(response_data, http_res)
656
602
  if utils.match_response(http_res, "4XX", "*"):
657
603
  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
- )
604
+ raise errors.APIError("API error occurred", http_res, http_res_text)
661
605
  if utils.match_response(http_res, "5XX", "*"):
662
606
  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
- )
607
+ raise errors.APIError("API error occurred", http_res, http_res_text)
666
608
 
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
- )
609
+ raise errors.APIError("Unexpected response received", http_res)
675
610
 
676
611
  def update(
677
612
  self,
@@ -761,31 +696,20 @@ class Workflows(BaseSDK):
761
696
 
762
697
  response_data: Any = None
763
698
  if utils.match_response(http_res, "200", "application/json"):
764
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
699
+ return unmarshal_json_response(models.InsightWorkflowOutput, http_res)
765
700
  if utils.match_response(http_res, "422", "application/json"):
766
- response_data = utils.unmarshal_json(
767
- http_res.text, models.HTTPValidationErrorData
701
+ response_data = unmarshal_json_response(
702
+ errors.HTTPValidationErrorData, http_res
768
703
  )
769
- raise models.HTTPValidationError(data=response_data)
704
+ raise errors.HTTPValidationError(response_data, http_res)
770
705
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
771
706
  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
- )
707
+ raise errors.APIError("API error occurred", http_res, http_res_text)
775
708
  if utils.match_response(http_res, ["500", "5XX"], "*"):
776
709
  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
- )
710
+ raise errors.APIError("API error occurred", http_res, http_res_text)
780
711
 
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
- )
712
+ raise errors.APIError("Unexpected response received", http_res)
789
713
 
790
714
  async def update_async(
791
715
  self,
@@ -875,31 +799,20 @@ class Workflows(BaseSDK):
875
799
 
876
800
  response_data: Any = None
877
801
  if utils.match_response(http_res, "200", "application/json"):
878
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
802
+ return unmarshal_json_response(models.InsightWorkflowOutput, http_res)
879
803
  if utils.match_response(http_res, "422", "application/json"):
880
- response_data = utils.unmarshal_json(
881
- http_res.text, models.HTTPValidationErrorData
804
+ response_data = unmarshal_json_response(
805
+ errors.HTTPValidationErrorData, http_res
882
806
  )
883
- raise models.HTTPValidationError(data=response_data)
807
+ raise errors.HTTPValidationError(response_data, http_res)
884
808
  if utils.match_response(http_res, ["400", "404", "412", "4XX"], "*"):
885
809
  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
- )
810
+ raise errors.APIError("API error occurred", http_res, http_res_text)
889
811
  if utils.match_response(http_res, ["500", "5XX"], "*"):
890
812
  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
- )
813
+ raise errors.APIError("API error occurred", http_res, http_res_text)
894
814
 
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
- )
815
+ raise errors.APIError("Unexpected response received", http_res)
903
816
 
904
817
  def delete(
905
818
  self,
@@ -975,31 +888,20 @@ class Workflows(BaseSDK):
975
888
 
976
889
  response_data: Any = None
977
890
  if utils.match_response(http_res, "200", "application/json"):
978
- return utils.unmarshal_json(http_res.text, Any)
891
+ return unmarshal_json_response(Any, http_res)
979
892
  if utils.match_response(http_res, "422", "application/json"):
980
- response_data = utils.unmarshal_json(
981
- http_res.text, models.HTTPValidationErrorData
893
+ response_data = unmarshal_json_response(
894
+ errors.HTTPValidationErrorData, http_res
982
895
  )
983
- raise models.HTTPValidationError(data=response_data)
896
+ raise errors.HTTPValidationError(response_data, http_res)
984
897
  if utils.match_response(http_res, ["400", "404", "4XX"], "*"):
985
898
  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
- )
899
+ raise errors.APIError("API error occurred", http_res, http_res_text)
989
900
  if utils.match_response(http_res, ["500", "5XX"], "*"):
990
901
  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
- )
902
+ raise errors.APIError("API error occurred", http_res, http_res_text)
994
903
 
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
- )
904
+ raise errors.APIError("Unexpected response received", http_res)
1003
905
 
1004
906
  async def delete_async(
1005
907
  self,
@@ -1075,31 +977,20 @@ class Workflows(BaseSDK):
1075
977
 
1076
978
  response_data: Any = None
1077
979
  if utils.match_response(http_res, "200", "application/json"):
1078
- return utils.unmarshal_json(http_res.text, Any)
980
+ return unmarshal_json_response(Any, http_res)
1079
981
  if utils.match_response(http_res, "422", "application/json"):
1080
- response_data = utils.unmarshal_json(
1081
- http_res.text, models.HTTPValidationErrorData
982
+ response_data = unmarshal_json_response(
983
+ errors.HTTPValidationErrorData, http_res
1082
984
  )
1083
- raise models.HTTPValidationError(data=response_data)
985
+ raise errors.HTTPValidationError(response_data, http_res)
1084
986
  if utils.match_response(http_res, ["400", "404", "4XX"], "*"):
1085
987
  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
- )
988
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1089
989
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1090
990
  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
- )
991
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1094
992
 
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
- )
993
+ raise errors.APIError("Unexpected response received", http_res)
1103
994
 
1104
995
  def inactivate(
1105
996
  self,
@@ -1175,31 +1066,20 @@ class Workflows(BaseSDK):
1175
1066
 
1176
1067
  response_data: Any = None
1177
1068
  if utils.match_response(http_res, "200", "application/json"):
1178
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
1069
+ return unmarshal_json_response(models.InsightWorkflowOutput, http_res)
1179
1070
  if utils.match_response(http_res, "422", "application/json"):
1180
- response_data = utils.unmarshal_json(
1181
- http_res.text, models.HTTPValidationErrorData
1071
+ response_data = unmarshal_json_response(
1072
+ errors.HTTPValidationErrorData, http_res
1182
1073
  )
1183
- raise models.HTTPValidationError(data=response_data)
1074
+ raise errors.HTTPValidationError(response_data, http_res)
1184
1075
  if utils.match_response(http_res, ["404", "4XX"], "*"):
1185
1076
  http_res_text = utils.stream_to_text(http_res)
1186
- raise models.APIError(
1187
- "API error occurred", http_res.status_code, http_res_text, http_res
1188
- )
1077
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1189
1078
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1190
1079
  http_res_text = utils.stream_to_text(http_res)
1191
- raise models.APIError(
1192
- "API error occurred", http_res.status_code, http_res_text, http_res
1193
- )
1080
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1194
1081
 
1195
- content_type = http_res.headers.get("Content-Type")
1196
- 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
- )
1082
+ raise errors.APIError("Unexpected response received", http_res)
1203
1083
 
1204
1084
  async def inactivate_async(
1205
1085
  self,
@@ -1275,31 +1155,20 @@ class Workflows(BaseSDK):
1275
1155
 
1276
1156
  response_data: Any = None
1277
1157
  if utils.match_response(http_res, "200", "application/json"):
1278
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
1158
+ return unmarshal_json_response(models.InsightWorkflowOutput, http_res)
1279
1159
  if utils.match_response(http_res, "422", "application/json"):
1280
- response_data = utils.unmarshal_json(
1281
- http_res.text, models.HTTPValidationErrorData
1160
+ response_data = unmarshal_json_response(
1161
+ errors.HTTPValidationErrorData, http_res
1282
1162
  )
1283
- raise models.HTTPValidationError(data=response_data)
1163
+ raise errors.HTTPValidationError(response_data, http_res)
1284
1164
  if utils.match_response(http_res, ["404", "4XX"], "*"):
1285
1165
  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
- )
1166
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1289
1167
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1290
1168
  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
- )
1169
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1294
1170
 
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
- )
1171
+ raise errors.APIError("Unexpected response received", http_res)
1303
1172
 
1304
1173
  def activate(
1305
1174
  self,
@@ -1389,31 +1258,20 @@ class Workflows(BaseSDK):
1389
1258
 
1390
1259
  response_data: Any = None
1391
1260
  if utils.match_response(http_res, "200", "application/json"):
1392
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
1261
+ return unmarshal_json_response(models.InsightWorkflowOutput, http_res)
1393
1262
  if utils.match_response(http_res, "422", "application/json"):
1394
- response_data = utils.unmarshal_json(
1395
- http_res.text, models.HTTPValidationErrorData
1263
+ response_data = unmarshal_json_response(
1264
+ errors.HTTPValidationErrorData, http_res
1396
1265
  )
1397
- raise models.HTTPValidationError(data=response_data)
1266
+ raise errors.HTTPValidationError(response_data, http_res)
1398
1267
  if utils.match_response(http_res, ["404", "4XX"], "*"):
1399
1268
  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
- )
1269
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1403
1270
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1404
1271
  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
- )
1272
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1408
1273
 
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
- )
1274
+ raise errors.APIError("Unexpected response received", http_res)
1417
1275
 
1418
1276
  async def activate_async(
1419
1277
  self,
@@ -1503,31 +1361,20 @@ class Workflows(BaseSDK):
1503
1361
 
1504
1362
  response_data: Any = None
1505
1363
  if utils.match_response(http_res, "200", "application/json"):
1506
- return utils.unmarshal_json(http_res.text, models.InsightWorkflowOutput)
1364
+ return unmarshal_json_response(models.InsightWorkflowOutput, http_res)
1507
1365
  if utils.match_response(http_res, "422", "application/json"):
1508
- response_data = utils.unmarshal_json(
1509
- http_res.text, models.HTTPValidationErrorData
1366
+ response_data = unmarshal_json_response(
1367
+ errors.HTTPValidationErrorData, http_res
1510
1368
  )
1511
- raise models.HTTPValidationError(data=response_data)
1369
+ raise errors.HTTPValidationError(response_data, http_res)
1512
1370
  if utils.match_response(http_res, ["404", "4XX"], "*"):
1513
1371
  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
- )
1372
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1517
1373
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1518
1374
  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
- )
1375
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1522
1376
 
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
- )
1377
+ raise errors.APIError("Unexpected response received", http_res)
1531
1378
 
1532
1379
  def queue_work(
1533
1380
  self,
@@ -1609,31 +1456,20 @@ class Workflows(BaseSDK):
1609
1456
 
1610
1457
  response_data: Any = None
1611
1458
  if utils.match_response(http_res, "200", "application/json"):
1612
- return utils.unmarshal_json(http_res.text, Any)
1459
+ return unmarshal_json_response(Any, http_res)
1613
1460
  if utils.match_response(http_res, "422", "application/json"):
1614
- response_data = utils.unmarshal_json(
1615
- http_res.text, models.HTTPValidationErrorData
1461
+ response_data = unmarshal_json_response(
1462
+ errors.HTTPValidationErrorData, http_res
1616
1463
  )
1617
- raise models.HTTPValidationError(data=response_data)
1464
+ raise errors.HTTPValidationError(response_data, http_res)
1618
1465
  if utils.match_response(http_res, ["400", "404", "4XX"], "*"):
1619
1466
  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
- )
1467
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1623
1468
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1624
1469
  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
- )
1470
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1628
1471
 
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
- )
1472
+ raise errors.APIError("Unexpected response received", http_res)
1637
1473
 
1638
1474
  async def queue_work_async(
1639
1475
  self,
@@ -1715,28 +1551,17 @@ class Workflows(BaseSDK):
1715
1551
 
1716
1552
  response_data: Any = None
1717
1553
  if utils.match_response(http_res, "200", "application/json"):
1718
- return utils.unmarshal_json(http_res.text, Any)
1554
+ return unmarshal_json_response(Any, http_res)
1719
1555
  if utils.match_response(http_res, "422", "application/json"):
1720
- response_data = utils.unmarshal_json(
1721
- http_res.text, models.HTTPValidationErrorData
1556
+ response_data = unmarshal_json_response(
1557
+ errors.HTTPValidationErrorData, http_res
1722
1558
  )
1723
- raise models.HTTPValidationError(data=response_data)
1559
+ raise errors.HTTPValidationError(response_data, http_res)
1724
1560
  if utils.match_response(http_res, ["400", "404", "4XX"], "*"):
1725
1561
  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
- )
1562
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1729
1563
  if utils.match_response(http_res, ["500", "5XX"], "*"):
1730
1564
  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
- )
1565
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1734
1566
 
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
- )
1567
+ raise errors.APIError("Unexpected response received", http_res)