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/services.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 Services(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.ListResponseServiceResponse
112
+ return utils.unmarshal_json_response(
113
+ models.ListResponseServiceResponse, 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 Services(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.ListResponseServiceResponse
227
+ return utils.unmarshal_json_response(
228
+ models.ListResponseServiceResponse, 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 Services(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.ServiceResponse)
323
+ return utils.unmarshal_json_response(models.ServiceResponse, 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 Services(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.ServiceResponse)
417
+ return utils.unmarshal_json_response(models.ServiceResponse, 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 update(
477
433
  self,
@@ -552,31 +508,20 @@ class Services(BaseSDK):
552
508
 
553
509
  response_data: Any = None
554
510
  if utils.match_response(http_res, "200", "application/json"):
555
- return utils.unmarshal_json(http_res.text, models.ServiceResponse)
511
+ return utils.unmarshal_json_response(models.ServiceResponse, http_res)
556
512
  if utils.match_response(http_res, "422", "application/json"):
557
- response_data = utils.unmarshal_json(
558
- http_res.text, models.HTTPValidationErrorData
513
+ response_data = utils.unmarshal_json_response(
514
+ errors.HTTPValidationErrorData, http_res
559
515
  )
560
- raise models.HTTPValidationError(data=response_data)
516
+ raise errors.HTTPValidationError(response_data, http_res)
561
517
  if utils.match_response(http_res, "4XX", "*"):
562
518
  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
- )
519
+ raise errors.APIError("API error occurred", http_res, http_res_text)
566
520
  if utils.match_response(http_res, "5XX", "*"):
567
521
  http_res_text = utils.stream_to_text(http_res)
568
- raise models.APIError(
569
- "API error occurred", http_res.status_code, http_res_text, http_res
570
- )
522
+ raise errors.APIError("API error occurred", http_res, http_res_text)
571
523
 
572
- content_type = http_res.headers.get("Content-Type")
573
- http_res_text = utils.stream_to_text(http_res)
574
- raise models.APIError(
575
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
576
- http_res.status_code,
577
- http_res_text,
578
- http_res,
579
- )
524
+ raise errors.APIError("Unexpected response received", http_res)
580
525
 
581
526
  async def update_async(
582
527
  self,
@@ -657,31 +602,20 @@ class Services(BaseSDK):
657
602
 
658
603
  response_data: Any = None
659
604
  if utils.match_response(http_res, "200", "application/json"):
660
- return utils.unmarshal_json(http_res.text, models.ServiceResponse)
605
+ return utils.unmarshal_json_response(models.ServiceResponse, http_res)
661
606
  if utils.match_response(http_res, "422", "application/json"):
662
- response_data = utils.unmarshal_json(
663
- http_res.text, models.HTTPValidationErrorData
607
+ response_data = utils.unmarshal_json_response(
608
+ errors.HTTPValidationErrorData, http_res
664
609
  )
665
- raise models.HTTPValidationError(data=response_data)
610
+ raise errors.HTTPValidationError(response_data, http_res)
666
611
  if utils.match_response(http_res, "4XX", "*"):
667
612
  http_res_text = await utils.stream_to_text_async(http_res)
668
- raise models.APIError(
669
- "API error occurred", http_res.status_code, http_res_text, http_res
670
- )
613
+ raise errors.APIError("API error occurred", http_res, http_res_text)
671
614
  if utils.match_response(http_res, "5XX", "*"):
672
615
  http_res_text = await utils.stream_to_text_async(http_res)
673
- raise models.APIError(
674
- "API error occurred", http_res.status_code, http_res_text, http_res
675
- )
616
+ raise errors.APIError("API error occurred", http_res, http_res_text)
676
617
 
677
- content_type = http_res.headers.get("Content-Type")
678
- http_res_text = await utils.stream_to_text_async(http_res)
679
- raise models.APIError(
680
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
681
- http_res.status_code,
682
- http_res_text,
683
- http_res,
684
- )
618
+ raise errors.APIError("Unexpected response received", http_res)
685
619
 
686
620
  def get_by_id(
687
621
  self,
@@ -757,31 +691,20 @@ class Services(BaseSDK):
757
691
 
758
692
  response_data: Any = None
759
693
  if utils.match_response(http_res, "200", "application/json"):
760
- return utils.unmarshal_json(http_res.text, models.ServiceResponse)
694
+ return utils.unmarshal_json_response(models.ServiceResponse, http_res)
761
695
  if utils.match_response(http_res, "422", "application/json"):
762
- response_data = utils.unmarshal_json(
763
- http_res.text, models.HTTPValidationErrorData
696
+ response_data = utils.unmarshal_json_response(
697
+ errors.HTTPValidationErrorData, http_res
764
698
  )
765
- raise models.HTTPValidationError(data=response_data)
699
+ raise errors.HTTPValidationError(response_data, http_res)
766
700
  if utils.match_response(http_res, "4XX", "*"):
767
701
  http_res_text = utils.stream_to_text(http_res)
768
- raise models.APIError(
769
- "API error occurred", http_res.status_code, http_res_text, http_res
770
- )
702
+ raise errors.APIError("API error occurred", http_res, http_res_text)
771
703
  if utils.match_response(http_res, "5XX", "*"):
772
704
  http_res_text = utils.stream_to_text(http_res)
773
- raise models.APIError(
774
- "API error occurred", http_res.status_code, http_res_text, http_res
775
- )
705
+ raise errors.APIError("API error occurred", http_res, http_res_text)
776
706
 
777
- content_type = http_res.headers.get("Content-Type")
778
- http_res_text = utils.stream_to_text(http_res)
779
- raise models.APIError(
780
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
781
- http_res.status_code,
782
- http_res_text,
783
- http_res,
784
- )
707
+ raise errors.APIError("Unexpected response received", http_res)
785
708
 
786
709
  async def get_by_id_async(
787
710
  self,
@@ -857,31 +780,20 @@ class Services(BaseSDK):
857
780
 
858
781
  response_data: Any = None
859
782
  if utils.match_response(http_res, "200", "application/json"):
860
- return utils.unmarshal_json(http_res.text, models.ServiceResponse)
783
+ return utils.unmarshal_json_response(models.ServiceResponse, http_res)
861
784
  if utils.match_response(http_res, "422", "application/json"):
862
- response_data = utils.unmarshal_json(
863
- http_res.text, models.HTTPValidationErrorData
785
+ response_data = utils.unmarshal_json_response(
786
+ errors.HTTPValidationErrorData, http_res
864
787
  )
865
- raise models.HTTPValidationError(data=response_data)
788
+ raise errors.HTTPValidationError(response_data, http_res)
866
789
  if utils.match_response(http_res, "4XX", "*"):
867
790
  http_res_text = await utils.stream_to_text_async(http_res)
868
- raise models.APIError(
869
- "API error occurred", http_res.status_code, http_res_text, http_res
870
- )
791
+ raise errors.APIError("API error occurred", http_res, http_res_text)
871
792
  if utils.match_response(http_res, "5XX", "*"):
872
793
  http_res_text = await utils.stream_to_text_async(http_res)
873
- raise models.APIError(
874
- "API error occurred", http_res.status_code, http_res_text, http_res
875
- )
794
+ raise errors.APIError("API error occurred", http_res, http_res_text)
876
795
 
877
- content_type = http_res.headers.get("Content-Type")
878
- http_res_text = await utils.stream_to_text_async(http_res)
879
- raise models.APIError(
880
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
881
- http_res.status_code,
882
- http_res_text,
883
- http_res,
884
- )
796
+ raise errors.APIError("Unexpected response received", http_res)
885
797
 
886
798
  def delete(
887
799
  self,
@@ -960,31 +872,20 @@ class Services(BaseSDK):
960
872
 
961
873
  response_data: Any = None
962
874
  if utils.match_response(http_res, "200", "application/json"):
963
- return utils.unmarshal_json(http_res.text, Any)
875
+ return utils.unmarshal_json_response(Any, http_res)
964
876
  if utils.match_response(http_res, "422", "application/json"):
965
- response_data = utils.unmarshal_json(
966
- http_res.text, models.HTTPValidationErrorData
877
+ response_data = utils.unmarshal_json_response(
878
+ errors.HTTPValidationErrorData, http_res
967
879
  )
968
- raise models.HTTPValidationError(data=response_data)
880
+ raise errors.HTTPValidationError(response_data, http_res)
969
881
  if utils.match_response(http_res, "4XX", "*"):
970
882
  http_res_text = utils.stream_to_text(http_res)
971
- raise models.APIError(
972
- "API error occurred", http_res.status_code, http_res_text, http_res
973
- )
883
+ raise errors.APIError("API error occurred", http_res, http_res_text)
974
884
  if utils.match_response(http_res, "5XX", "*"):
975
885
  http_res_text = utils.stream_to_text(http_res)
976
- raise models.APIError(
977
- "API error occurred", http_res.status_code, http_res_text, http_res
978
- )
886
+ raise errors.APIError("API error occurred", http_res, http_res_text)
979
887
 
980
- content_type = http_res.headers.get("Content-Type")
981
- http_res_text = utils.stream_to_text(http_res)
982
- raise models.APIError(
983
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
984
- http_res.status_code,
985
- http_res_text,
986
- http_res,
987
- )
888
+ raise errors.APIError("Unexpected response received", http_res)
988
889
 
989
890
  async def delete_async(
990
891
  self,
@@ -1063,28 +964,17 @@ class Services(BaseSDK):
1063
964
 
1064
965
  response_data: Any = None
1065
966
  if utils.match_response(http_res, "200", "application/json"):
1066
- return utils.unmarshal_json(http_res.text, Any)
967
+ return utils.unmarshal_json_response(Any, http_res)
1067
968
  if utils.match_response(http_res, "422", "application/json"):
1068
- response_data = utils.unmarshal_json(
1069
- http_res.text, models.HTTPValidationErrorData
969
+ response_data = utils.unmarshal_json_response(
970
+ errors.HTTPValidationErrorData, http_res
1070
971
  )
1071
- raise models.HTTPValidationError(data=response_data)
972
+ raise errors.HTTPValidationError(response_data, http_res)
1072
973
  if utils.match_response(http_res, "4XX", "*"):
1073
974
  http_res_text = await utils.stream_to_text_async(http_res)
1074
- raise models.APIError(
1075
- "API error occurred", http_res.status_code, http_res_text, http_res
1076
- )
975
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1077
976
  if utils.match_response(http_res, "5XX", "*"):
1078
977
  http_res_text = await utils.stream_to_text_async(http_res)
1079
- raise models.APIError(
1080
- "API error occurred", http_res.status_code, http_res_text, http_res
1081
- )
978
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1082
979
 
1083
- content_type = http_res.headers.get("Content-Type")
1084
- http_res_text = await utils.stream_to_text_async(http_res)
1085
- raise models.APIError(
1086
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1087
- http_res.status_code,
1088
- http_res_text,
1089
- http_res,
1090
- )
980
+ raise errors.APIError("Unexpected response received", http_res)
@@ -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 OptionalNullable, UNSET
7
7
  from syllable_sdk.utils import get_security_from_env
@@ -84,31 +84,20 @@ class SessionDebug(BaseSDK):
84
84
 
85
85
  response_data: Any = None
86
86
  if utils.match_response(http_res, "200", "application/json"):
87
- return utils.unmarshal_json(http_res.text, models.SessionData)
87
+ return utils.unmarshal_json_response(models.SessionData, http_res)
88
88
  if utils.match_response(http_res, "422", "application/json"):
89
- response_data = utils.unmarshal_json(
90
- http_res.text, models.HTTPValidationErrorData
89
+ response_data = utils.unmarshal_json_response(
90
+ errors.HTTPValidationErrorData, http_res
91
91
  )
92
- raise models.HTTPValidationError(data=response_data)
92
+ raise errors.HTTPValidationError(response_data, http_res)
93
93
  if utils.match_response(http_res, "4XX", "*"):
94
94
  http_res_text = utils.stream_to_text(http_res)
95
- raise models.APIError(
96
- "API error occurred", http_res.status_code, http_res_text, http_res
97
- )
95
+ raise errors.APIError("API error occurred", http_res, http_res_text)
98
96
  if utils.match_response(http_res, "5XX", "*"):
99
97
  http_res_text = utils.stream_to_text(http_res)
100
- raise models.APIError(
101
- "API error occurred", http_res.status_code, http_res_text, http_res
102
- )
98
+ raise errors.APIError("API error occurred", http_res, http_res_text)
103
99
 
104
- content_type = http_res.headers.get("Content-Type")
105
- http_res_text = utils.stream_to_text(http_res)
106
- raise models.APIError(
107
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
108
- http_res.status_code,
109
- http_res_text,
110
- http_res,
111
- )
100
+ raise errors.APIError("Unexpected response received", http_res)
112
101
 
113
102
  async def get_session_data_by_sid_async(
114
103
  self,
@@ -185,31 +174,20 @@ class SessionDebug(BaseSDK):
185
174
 
186
175
  response_data: Any = None
187
176
  if utils.match_response(http_res, "200", "application/json"):
188
- return utils.unmarshal_json(http_res.text, models.SessionData)
177
+ return utils.unmarshal_json_response(models.SessionData, http_res)
189
178
  if utils.match_response(http_res, "422", "application/json"):
190
- response_data = utils.unmarshal_json(
191
- http_res.text, models.HTTPValidationErrorData
179
+ response_data = utils.unmarshal_json_response(
180
+ errors.HTTPValidationErrorData, http_res
192
181
  )
193
- raise models.HTTPValidationError(data=response_data)
182
+ raise errors.HTTPValidationError(response_data, http_res)
194
183
  if utils.match_response(http_res, "4XX", "*"):
195
184
  http_res_text = await utils.stream_to_text_async(http_res)
196
- raise models.APIError(
197
- "API error occurred", http_res.status_code, http_res_text, http_res
198
- )
185
+ raise errors.APIError("API error occurred", http_res, http_res_text)
199
186
  if utils.match_response(http_res, "5XX", "*"):
200
187
  http_res_text = await utils.stream_to_text_async(http_res)
201
- raise models.APIError(
202
- "API error occurred", http_res.status_code, http_res_text, http_res
203
- )
188
+ raise errors.APIError("API error occurred", http_res, http_res_text)
204
189
 
205
- content_type = http_res.headers.get("Content-Type")
206
- http_res_text = await utils.stream_to_text_async(http_res)
207
- raise models.APIError(
208
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
209
- http_res.status_code,
210
- http_res_text,
211
- http_res,
212
- )
190
+ raise errors.APIError("Unexpected response received", http_res)
213
191
 
214
192
  def get_session_data_by_session_id(
215
193
  self,
@@ -283,31 +261,20 @@ class SessionDebug(BaseSDK):
283
261
 
284
262
  response_data: Any = None
285
263
  if utils.match_response(http_res, "200", "application/json"):
286
- return utils.unmarshal_json(http_res.text, models.SessionData)
264
+ return utils.unmarshal_json_response(models.SessionData, http_res)
287
265
  if utils.match_response(http_res, "422", "application/json"):
288
- response_data = utils.unmarshal_json(
289
- http_res.text, models.HTTPValidationErrorData
266
+ response_data = utils.unmarshal_json_response(
267
+ errors.HTTPValidationErrorData, http_res
290
268
  )
291
- raise models.HTTPValidationError(data=response_data)
269
+ raise errors.HTTPValidationError(response_data, http_res)
292
270
  if utils.match_response(http_res, "4XX", "*"):
293
271
  http_res_text = utils.stream_to_text(http_res)
294
- raise models.APIError(
295
- "API error occurred", http_res.status_code, http_res_text, http_res
296
- )
272
+ raise errors.APIError("API error occurred", http_res, http_res_text)
297
273
  if utils.match_response(http_res, "5XX", "*"):
298
274
  http_res_text = utils.stream_to_text(http_res)
299
- raise models.APIError(
300
- "API error occurred", http_res.status_code, http_res_text, http_res
301
- )
275
+ raise errors.APIError("API error occurred", http_res, http_res_text)
302
276
 
303
- content_type = http_res.headers.get("Content-Type")
304
- http_res_text = utils.stream_to_text(http_res)
305
- raise models.APIError(
306
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
307
- http_res.status_code,
308
- http_res_text,
309
- http_res,
310
- )
277
+ raise errors.APIError("Unexpected response received", http_res)
311
278
 
312
279
  async def get_session_data_by_session_id_async(
313
280
  self,
@@ -381,31 +348,20 @@ class SessionDebug(BaseSDK):
381
348
 
382
349
  response_data: Any = None
383
350
  if utils.match_response(http_res, "200", "application/json"):
384
- return utils.unmarshal_json(http_res.text, models.SessionData)
351
+ return utils.unmarshal_json_response(models.SessionData, http_res)
385
352
  if utils.match_response(http_res, "422", "application/json"):
386
- response_data = utils.unmarshal_json(
387
- http_res.text, models.HTTPValidationErrorData
353
+ response_data = utils.unmarshal_json_response(
354
+ errors.HTTPValidationErrorData, http_res
388
355
  )
389
- raise models.HTTPValidationError(data=response_data)
356
+ raise errors.HTTPValidationError(response_data, http_res)
390
357
  if utils.match_response(http_res, "4XX", "*"):
391
358
  http_res_text = await utils.stream_to_text_async(http_res)
392
- raise models.APIError(
393
- "API error occurred", http_res.status_code, http_res_text, http_res
394
- )
359
+ raise errors.APIError("API error occurred", http_res, http_res_text)
395
360
  if utils.match_response(http_res, "5XX", "*"):
396
361
  http_res_text = await utils.stream_to_text_async(http_res)
397
- raise models.APIError(
398
- "API error occurred", http_res.status_code, http_res_text, http_res
399
- )
362
+ raise errors.APIError("API error occurred", http_res, http_res_text)
400
363
 
401
- content_type = http_res.headers.get("Content-Type")
402
- http_res_text = await utils.stream_to_text_async(http_res)
403
- raise models.APIError(
404
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
405
- http_res.status_code,
406
- http_res_text,
407
- http_res,
408
- )
364
+ raise errors.APIError("Unexpected response received", http_res)
409
365
 
410
366
  def get_session_tool_call_result_by_id(
411
367
  self,
@@ -482,31 +438,20 @@ class SessionDebug(BaseSDK):
482
438
 
483
439
  response_data: Any = None
484
440
  if utils.match_response(http_res, "200", "application/json"):
485
- return utils.unmarshal_json(http_res.text, models.ToolResultData)
441
+ return utils.unmarshal_json_response(models.ToolResultData, http_res)
486
442
  if utils.match_response(http_res, "422", "application/json"):
487
- response_data = utils.unmarshal_json(
488
- http_res.text, models.HTTPValidationErrorData
443
+ response_data = utils.unmarshal_json_response(
444
+ errors.HTTPValidationErrorData, http_res
489
445
  )
490
- raise models.HTTPValidationError(data=response_data)
446
+ raise errors.HTTPValidationError(response_data, http_res)
491
447
  if utils.match_response(http_res, "4XX", "*"):
492
448
  http_res_text = utils.stream_to_text(http_res)
493
- raise models.APIError(
494
- "API error occurred", http_res.status_code, http_res_text, http_res
495
- )
449
+ raise errors.APIError("API error occurred", http_res, http_res_text)
496
450
  if utils.match_response(http_res, "5XX", "*"):
497
451
  http_res_text = utils.stream_to_text(http_res)
498
- raise models.APIError(
499
- "API error occurred", http_res.status_code, http_res_text, http_res
500
- )
452
+ raise errors.APIError("API error occurred", http_res, http_res_text)
501
453
 
502
- content_type = http_res.headers.get("Content-Type")
503
- http_res_text = utils.stream_to_text(http_res)
504
- raise models.APIError(
505
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
506
- http_res.status_code,
507
- http_res_text,
508
- http_res,
509
- )
454
+ raise errors.APIError("Unexpected response received", http_res)
510
455
 
511
456
  async def get_session_tool_call_result_by_id_async(
512
457
  self,
@@ -583,28 +528,17 @@ class SessionDebug(BaseSDK):
583
528
 
584
529
  response_data: Any = None
585
530
  if utils.match_response(http_res, "200", "application/json"):
586
- return utils.unmarshal_json(http_res.text, models.ToolResultData)
531
+ return utils.unmarshal_json_response(models.ToolResultData, http_res)
587
532
  if utils.match_response(http_res, "422", "application/json"):
588
- response_data = utils.unmarshal_json(
589
- http_res.text, models.HTTPValidationErrorData
533
+ response_data = utils.unmarshal_json_response(
534
+ errors.HTTPValidationErrorData, http_res
590
535
  )
591
- raise models.HTTPValidationError(data=response_data)
536
+ raise errors.HTTPValidationError(response_data, http_res)
592
537
  if utils.match_response(http_res, "4XX", "*"):
593
538
  http_res_text = await utils.stream_to_text_async(http_res)
594
- raise models.APIError(
595
- "API error occurred", http_res.status_code, http_res_text, http_res
596
- )
539
+ raise errors.APIError("API error occurred", http_res, http_res_text)
597
540
  if utils.match_response(http_res, "5XX", "*"):
598
541
  http_res_text = await utils.stream_to_text_async(http_res)
599
- raise models.APIError(
600
- "API error occurred", http_res.status_code, http_res_text, http_res
601
- )
542
+ raise errors.APIError("API error occurred", http_res, http_res_text)
602
543
 
603
- content_type = http_res.headers.get("Content-Type")
604
- http_res_text = await utils.stream_to_text_async(http_res)
605
- raise models.APIError(
606
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
607
- http_res.status_code,
608
- http_res_text,
609
- http_res,
610
- )
544
+ raise errors.APIError("Unexpected response received", http_res)