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/services.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,20 @@ class Services(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.ListResponseServiceResponse
114
- )
113
+ return unmarshal_json_response(models.ListResponseServiceResponse, http_res)
115
114
  if utils.match_response(http_res, "422", "application/json"):
116
- response_data = utils.unmarshal_json(
117
- http_res.text, models.HTTPValidationErrorData
115
+ response_data = unmarshal_json_response(
116
+ errors.HTTPValidationErrorData, http_res
118
117
  )
119
- raise models.HTTPValidationError(data=response_data)
118
+ raise errors.HTTPValidationError(response_data, http_res)
120
119
  if utils.match_response(http_res, "4XX", "*"):
121
120
  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
- )
121
+ raise errors.APIError("API error occurred", http_res, http_res_text)
125
122
  if utils.match_response(http_res, "5XX", "*"):
126
123
  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
- )
124
+ raise errors.APIError("API error occurred", http_res, http_res_text)
130
125
 
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
- )
126
+ raise errors.APIError("Unexpected response received", http_res)
139
127
 
140
128
  async def list_async(
141
129
  self,
@@ -235,33 +223,20 @@ class Services(BaseSDK):
235
223
 
236
224
  response_data: Any = None
237
225
  if utils.match_response(http_res, "200", "application/json"):
238
- return utils.unmarshal_json(
239
- http_res.text, models.ListResponseServiceResponse
240
- )
226
+ return unmarshal_json_response(models.ListResponseServiceResponse, http_res)
241
227
  if utils.match_response(http_res, "422", "application/json"):
242
- response_data = utils.unmarshal_json(
243
- http_res.text, models.HTTPValidationErrorData
228
+ response_data = unmarshal_json_response(
229
+ errors.HTTPValidationErrorData, http_res
244
230
  )
245
- raise models.HTTPValidationError(data=response_data)
231
+ raise errors.HTTPValidationError(response_data, http_res)
246
232
  if utils.match_response(http_res, "4XX", "*"):
247
233
  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
- )
234
+ raise errors.APIError("API error occurred", http_res, http_res_text)
251
235
  if utils.match_response(http_res, "5XX", "*"):
252
236
  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
- )
237
+ raise errors.APIError("API error occurred", http_res, http_res_text)
256
238
 
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
- )
239
+ raise errors.APIError("Unexpected response received", http_res)
265
240
 
266
241
  def create(
267
242
  self,
@@ -342,31 +317,20 @@ class Services(BaseSDK):
342
317
 
343
318
  response_data: Any = None
344
319
  if utils.match_response(http_res, "200", "application/json"):
345
- return utils.unmarshal_json(http_res.text, models.ServiceResponse)
320
+ return unmarshal_json_response(models.ServiceResponse, http_res)
346
321
  if utils.match_response(http_res, "422", "application/json"):
347
- response_data = utils.unmarshal_json(
348
- http_res.text, models.HTTPValidationErrorData
322
+ response_data = unmarshal_json_response(
323
+ errors.HTTPValidationErrorData, http_res
349
324
  )
350
- raise models.HTTPValidationError(data=response_data)
325
+ raise errors.HTTPValidationError(response_data, http_res)
351
326
  if utils.match_response(http_res, "4XX", "*"):
352
327
  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
- )
328
+ raise errors.APIError("API error occurred", http_res, http_res_text)
356
329
  if utils.match_response(http_res, "5XX", "*"):
357
330
  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
- )
331
+ raise errors.APIError("API error occurred", http_res, http_res_text)
361
332
 
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
- )
333
+ raise errors.APIError("Unexpected response received", http_res)
370
334
 
371
335
  async def create_async(
372
336
  self,
@@ -447,31 +411,20 @@ class Services(BaseSDK):
447
411
 
448
412
  response_data: Any = None
449
413
  if utils.match_response(http_res, "200", "application/json"):
450
- return utils.unmarshal_json(http_res.text, models.ServiceResponse)
414
+ return unmarshal_json_response(models.ServiceResponse, http_res)
451
415
  if utils.match_response(http_res, "422", "application/json"):
452
- response_data = utils.unmarshal_json(
453
- http_res.text, models.HTTPValidationErrorData
416
+ response_data = unmarshal_json_response(
417
+ errors.HTTPValidationErrorData, http_res
454
418
  )
455
- raise models.HTTPValidationError(data=response_data)
419
+ raise errors.HTTPValidationError(response_data, http_res)
456
420
  if utils.match_response(http_res, "4XX", "*"):
457
421
  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
- )
422
+ raise errors.APIError("API error occurred", http_res, http_res_text)
461
423
  if utils.match_response(http_res, "5XX", "*"):
462
424
  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
- )
425
+ raise errors.APIError("API error occurred", http_res, http_res_text)
466
426
 
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
- )
427
+ raise errors.APIError("Unexpected response received", http_res)
475
428
 
476
429
  def update(
477
430
  self,
@@ -552,31 +505,20 @@ class Services(BaseSDK):
552
505
 
553
506
  response_data: Any = None
554
507
  if utils.match_response(http_res, "200", "application/json"):
555
- return utils.unmarshal_json(http_res.text, models.ServiceResponse)
508
+ return unmarshal_json_response(models.ServiceResponse, http_res)
556
509
  if utils.match_response(http_res, "422", "application/json"):
557
- response_data = utils.unmarshal_json(
558
- http_res.text, models.HTTPValidationErrorData
510
+ response_data = unmarshal_json_response(
511
+ errors.HTTPValidationErrorData, http_res
559
512
  )
560
- raise models.HTTPValidationError(data=response_data)
513
+ raise errors.HTTPValidationError(response_data, http_res)
561
514
  if utils.match_response(http_res, "4XX", "*"):
562
515
  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
- )
516
+ raise errors.APIError("API error occurred", http_res, http_res_text)
566
517
  if utils.match_response(http_res, "5XX", "*"):
567
518
  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
- )
519
+ raise errors.APIError("API error occurred", http_res, http_res_text)
571
520
 
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
- )
521
+ raise errors.APIError("Unexpected response received", http_res)
580
522
 
581
523
  async def update_async(
582
524
  self,
@@ -657,31 +599,20 @@ class Services(BaseSDK):
657
599
 
658
600
  response_data: Any = None
659
601
  if utils.match_response(http_res, "200", "application/json"):
660
- return utils.unmarshal_json(http_res.text, models.ServiceResponse)
602
+ return unmarshal_json_response(models.ServiceResponse, http_res)
661
603
  if utils.match_response(http_res, "422", "application/json"):
662
- response_data = utils.unmarshal_json(
663
- http_res.text, models.HTTPValidationErrorData
604
+ response_data = unmarshal_json_response(
605
+ errors.HTTPValidationErrorData, http_res
664
606
  )
665
- raise models.HTTPValidationError(data=response_data)
607
+ raise errors.HTTPValidationError(response_data, http_res)
666
608
  if utils.match_response(http_res, "4XX", "*"):
667
609
  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
- )
610
+ raise errors.APIError("API error occurred", http_res, http_res_text)
671
611
  if utils.match_response(http_res, "5XX", "*"):
672
612
  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
- )
613
+ raise errors.APIError("API error occurred", http_res, http_res_text)
676
614
 
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
- )
615
+ raise errors.APIError("Unexpected response received", http_res)
685
616
 
686
617
  def get_by_id(
687
618
  self,
@@ -757,31 +688,20 @@ class Services(BaseSDK):
757
688
 
758
689
  response_data: Any = None
759
690
  if utils.match_response(http_res, "200", "application/json"):
760
- return utils.unmarshal_json(http_res.text, models.ServiceResponse)
691
+ return unmarshal_json_response(models.ServiceResponse, http_res)
761
692
  if utils.match_response(http_res, "422", "application/json"):
762
- response_data = utils.unmarshal_json(
763
- http_res.text, models.HTTPValidationErrorData
693
+ response_data = unmarshal_json_response(
694
+ errors.HTTPValidationErrorData, http_res
764
695
  )
765
- raise models.HTTPValidationError(data=response_data)
696
+ raise errors.HTTPValidationError(response_data, http_res)
766
697
  if utils.match_response(http_res, "4XX", "*"):
767
698
  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
- )
699
+ raise errors.APIError("API error occurred", http_res, http_res_text)
771
700
  if utils.match_response(http_res, "5XX", "*"):
772
701
  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
- )
702
+ raise errors.APIError("API error occurred", http_res, http_res_text)
776
703
 
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
- )
704
+ raise errors.APIError("Unexpected response received", http_res)
785
705
 
786
706
  async def get_by_id_async(
787
707
  self,
@@ -857,31 +777,20 @@ class Services(BaseSDK):
857
777
 
858
778
  response_data: Any = None
859
779
  if utils.match_response(http_res, "200", "application/json"):
860
- return utils.unmarshal_json(http_res.text, models.ServiceResponse)
780
+ return unmarshal_json_response(models.ServiceResponse, http_res)
861
781
  if utils.match_response(http_res, "422", "application/json"):
862
- response_data = utils.unmarshal_json(
863
- http_res.text, models.HTTPValidationErrorData
782
+ response_data = unmarshal_json_response(
783
+ errors.HTTPValidationErrorData, http_res
864
784
  )
865
- raise models.HTTPValidationError(data=response_data)
785
+ raise errors.HTTPValidationError(response_data, http_res)
866
786
  if utils.match_response(http_res, "4XX", "*"):
867
787
  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
- )
788
+ raise errors.APIError("API error occurred", http_res, http_res_text)
871
789
  if utils.match_response(http_res, "5XX", "*"):
872
790
  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
- )
791
+ raise errors.APIError("API error occurred", http_res, http_res_text)
876
792
 
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
- )
793
+ raise errors.APIError("Unexpected response received", http_res)
885
794
 
886
795
  def delete(
887
796
  self,
@@ -960,31 +869,20 @@ class Services(BaseSDK):
960
869
 
961
870
  response_data: Any = None
962
871
  if utils.match_response(http_res, "200", "application/json"):
963
- return utils.unmarshal_json(http_res.text, Any)
872
+ return unmarshal_json_response(Any, http_res)
964
873
  if utils.match_response(http_res, "422", "application/json"):
965
- response_data = utils.unmarshal_json(
966
- http_res.text, models.HTTPValidationErrorData
874
+ response_data = unmarshal_json_response(
875
+ errors.HTTPValidationErrorData, http_res
967
876
  )
968
- raise models.HTTPValidationError(data=response_data)
877
+ raise errors.HTTPValidationError(response_data, http_res)
969
878
  if utils.match_response(http_res, "4XX", "*"):
970
879
  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
- )
880
+ raise errors.APIError("API error occurred", http_res, http_res_text)
974
881
  if utils.match_response(http_res, "5XX", "*"):
975
882
  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
- )
883
+ raise errors.APIError("API error occurred", http_res, http_res_text)
979
884
 
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
- )
885
+ raise errors.APIError("Unexpected response received", http_res)
988
886
 
989
887
  async def delete_async(
990
888
  self,
@@ -1063,28 +961,17 @@ class Services(BaseSDK):
1063
961
 
1064
962
  response_data: Any = None
1065
963
  if utils.match_response(http_res, "200", "application/json"):
1066
- return utils.unmarshal_json(http_res.text, Any)
964
+ return unmarshal_json_response(Any, http_res)
1067
965
  if utils.match_response(http_res, "422", "application/json"):
1068
- response_data = utils.unmarshal_json(
1069
- http_res.text, models.HTTPValidationErrorData
966
+ response_data = unmarshal_json_response(
967
+ errors.HTTPValidationErrorData, http_res
1070
968
  )
1071
- raise models.HTTPValidationError(data=response_data)
969
+ raise errors.HTTPValidationError(response_data, http_res)
1072
970
  if utils.match_response(http_res, "4XX", "*"):
1073
971
  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
- )
972
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1077
973
  if utils.match_response(http_res, "5XX", "*"):
1078
974
  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
- )
975
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1082
976
 
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
- )
977
+ raise errors.APIError("Unexpected response received", http_res)
@@ -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 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, Mapping, Optional
9
10
 
10
11
 
@@ -84,31 +85,20 @@ class SessionDebug(BaseSDK):
84
85
 
85
86
  response_data: Any = None
86
87
  if utils.match_response(http_res, "200", "application/json"):
87
- return utils.unmarshal_json(http_res.text, models.SessionData)
88
+ return unmarshal_json_response(models.SessionData, http_res)
88
89
  if utils.match_response(http_res, "422", "application/json"):
89
- response_data = utils.unmarshal_json(
90
- http_res.text, models.HTTPValidationErrorData
90
+ response_data = unmarshal_json_response(
91
+ errors.HTTPValidationErrorData, http_res
91
92
  )
92
- raise models.HTTPValidationError(data=response_data)
93
+ raise errors.HTTPValidationError(response_data, http_res)
93
94
  if utils.match_response(http_res, "4XX", "*"):
94
95
  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
- )
96
+ raise errors.APIError("API error occurred", http_res, http_res_text)
98
97
  if utils.match_response(http_res, "5XX", "*"):
99
98
  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
- )
99
+ raise errors.APIError("API error occurred", http_res, http_res_text)
103
100
 
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
- )
101
+ raise errors.APIError("Unexpected response received", http_res)
112
102
 
113
103
  async def get_session_data_by_sid_async(
114
104
  self,
@@ -185,31 +175,20 @@ class SessionDebug(BaseSDK):
185
175
 
186
176
  response_data: Any = None
187
177
  if utils.match_response(http_res, "200", "application/json"):
188
- return utils.unmarshal_json(http_res.text, models.SessionData)
178
+ return unmarshal_json_response(models.SessionData, http_res)
189
179
  if utils.match_response(http_res, "422", "application/json"):
190
- response_data = utils.unmarshal_json(
191
- http_res.text, models.HTTPValidationErrorData
180
+ response_data = unmarshal_json_response(
181
+ errors.HTTPValidationErrorData, http_res
192
182
  )
193
- raise models.HTTPValidationError(data=response_data)
183
+ raise errors.HTTPValidationError(response_data, http_res)
194
184
  if utils.match_response(http_res, "4XX", "*"):
195
185
  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
- )
186
+ raise errors.APIError("API error occurred", http_res, http_res_text)
199
187
  if utils.match_response(http_res, "5XX", "*"):
200
188
  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
- )
189
+ raise errors.APIError("API error occurred", http_res, http_res_text)
204
190
 
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
- )
191
+ raise errors.APIError("Unexpected response received", http_res)
213
192
 
214
193
  def get_session_data_by_session_id(
215
194
  self,
@@ -283,31 +262,20 @@ class SessionDebug(BaseSDK):
283
262
 
284
263
  response_data: Any = None
285
264
  if utils.match_response(http_res, "200", "application/json"):
286
- return utils.unmarshal_json(http_res.text, models.SessionData)
265
+ return unmarshal_json_response(models.SessionData, http_res)
287
266
  if utils.match_response(http_res, "422", "application/json"):
288
- response_data = utils.unmarshal_json(
289
- http_res.text, models.HTTPValidationErrorData
267
+ response_data = unmarshal_json_response(
268
+ errors.HTTPValidationErrorData, http_res
290
269
  )
291
- raise models.HTTPValidationError(data=response_data)
270
+ raise errors.HTTPValidationError(response_data, http_res)
292
271
  if utils.match_response(http_res, "4XX", "*"):
293
272
  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
- )
273
+ raise errors.APIError("API error occurred", http_res, http_res_text)
297
274
  if utils.match_response(http_res, "5XX", "*"):
298
275
  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
- )
276
+ raise errors.APIError("API error occurred", http_res, http_res_text)
302
277
 
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
- )
278
+ raise errors.APIError("Unexpected response received", http_res)
311
279
 
312
280
  async def get_session_data_by_session_id_async(
313
281
  self,
@@ -381,31 +349,20 @@ class SessionDebug(BaseSDK):
381
349
 
382
350
  response_data: Any = None
383
351
  if utils.match_response(http_res, "200", "application/json"):
384
- return utils.unmarshal_json(http_res.text, models.SessionData)
352
+ return unmarshal_json_response(models.SessionData, http_res)
385
353
  if utils.match_response(http_res, "422", "application/json"):
386
- response_data = utils.unmarshal_json(
387
- http_res.text, models.HTTPValidationErrorData
354
+ response_data = unmarshal_json_response(
355
+ errors.HTTPValidationErrorData, http_res
388
356
  )
389
- raise models.HTTPValidationError(data=response_data)
357
+ raise errors.HTTPValidationError(response_data, http_res)
390
358
  if utils.match_response(http_res, "4XX", "*"):
391
359
  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
- )
360
+ raise errors.APIError("API error occurred", http_res, http_res_text)
395
361
  if utils.match_response(http_res, "5XX", "*"):
396
362
  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
- )
363
+ raise errors.APIError("API error occurred", http_res, http_res_text)
400
364
 
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
- )
365
+ raise errors.APIError("Unexpected response received", http_res)
409
366
 
410
367
  def get_session_tool_call_result_by_id(
411
368
  self,
@@ -482,31 +439,20 @@ class SessionDebug(BaseSDK):
482
439
 
483
440
  response_data: Any = None
484
441
  if utils.match_response(http_res, "200", "application/json"):
485
- return utils.unmarshal_json(http_res.text, models.ToolResultData)
442
+ return unmarshal_json_response(models.ToolResultData, http_res)
486
443
  if utils.match_response(http_res, "422", "application/json"):
487
- response_data = utils.unmarshal_json(
488
- http_res.text, models.HTTPValidationErrorData
444
+ response_data = unmarshal_json_response(
445
+ errors.HTTPValidationErrorData, http_res
489
446
  )
490
- raise models.HTTPValidationError(data=response_data)
447
+ raise errors.HTTPValidationError(response_data, http_res)
491
448
  if utils.match_response(http_res, "4XX", "*"):
492
449
  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
- )
450
+ raise errors.APIError("API error occurred", http_res, http_res_text)
496
451
  if utils.match_response(http_res, "5XX", "*"):
497
452
  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
- )
453
+ raise errors.APIError("API error occurred", http_res, http_res_text)
501
454
 
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
- )
455
+ raise errors.APIError("Unexpected response received", http_res)
510
456
 
511
457
  async def get_session_tool_call_result_by_id_async(
512
458
  self,
@@ -583,28 +529,17 @@ class SessionDebug(BaseSDK):
583
529
 
584
530
  response_data: Any = None
585
531
  if utils.match_response(http_res, "200", "application/json"):
586
- return utils.unmarshal_json(http_res.text, models.ToolResultData)
532
+ return unmarshal_json_response(models.ToolResultData, http_res)
587
533
  if utils.match_response(http_res, "422", "application/json"):
588
- response_data = utils.unmarshal_json(
589
- http_res.text, models.HTTPValidationErrorData
534
+ response_data = unmarshal_json_response(
535
+ errors.HTTPValidationErrorData, http_res
590
536
  )
591
- raise models.HTTPValidationError(data=response_data)
537
+ raise errors.HTTPValidationError(response_data, http_res)
592
538
  if utils.match_response(http_res, "4XX", "*"):
593
539
  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
- )
540
+ raise errors.APIError("API error occurred", http_res, http_res_text)
597
541
  if utils.match_response(http_res, "5XX", "*"):
598
542
  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
- )
543
+ raise errors.APIError("API error occurred", http_res, http_res_text)
602
544
 
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
- )
545
+ raise errors.APIError("Unexpected response received", http_res)