syllable-sdk 0.35.31__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.31.dist-info → syllable_sdk-0.35.33.dist-info}/METADATA +58 -45
  48. {syllable_sdk-0.35.31.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.31.dist-info → syllable_sdk-0.35.33.dist-info}/WHEEL +0 -0
@@ -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 DataSources(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.ListResponseDataSourceMetadataResponse
112
+ return utils.unmarshal_json_response(
113
+ models.ListResponseDataSourceMetadataResponse, 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 DataSources(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.ListResponseDataSourceMetadataResponse
227
+ return utils.unmarshal_json_response(
228
+ models.ListResponseDataSourceMetadataResponse, 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,22 @@ class DataSources(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.DataSourceDetailResponse)
323
+ return utils.unmarshal_json_response(
324
+ models.DataSourceDetailResponse, http_res
325
+ )
346
326
  if utils.match_response(http_res, "422", "application/json"):
347
- response_data = utils.unmarshal_json(
348
- http_res.text, models.HTTPValidationErrorData
327
+ response_data = utils.unmarshal_json_response(
328
+ errors.HTTPValidationErrorData, http_res
349
329
  )
350
- raise models.HTTPValidationError(data=response_data)
330
+ raise errors.HTTPValidationError(response_data, http_res)
351
331
  if utils.match_response(http_res, "4XX", "*"):
352
332
  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
- )
333
+ raise errors.APIError("API error occurred", http_res, http_res_text)
356
334
  if utils.match_response(http_res, "5XX", "*"):
357
335
  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
- )
336
+ raise errors.APIError("API error occurred", http_res, http_res_text)
361
337
 
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
- )
338
+ raise errors.APIError("Unexpected response received", http_res)
370
339
 
371
340
  async def create_async(
372
341
  self,
@@ -447,31 +416,22 @@ class DataSources(BaseSDK):
447
416
 
448
417
  response_data: Any = None
449
418
  if utils.match_response(http_res, "200", "application/json"):
450
- return utils.unmarshal_json(http_res.text, models.DataSourceDetailResponse)
419
+ return utils.unmarshal_json_response(
420
+ models.DataSourceDetailResponse, http_res
421
+ )
451
422
  if utils.match_response(http_res, "422", "application/json"):
452
- response_data = utils.unmarshal_json(
453
- http_res.text, models.HTTPValidationErrorData
423
+ response_data = utils.unmarshal_json_response(
424
+ errors.HTTPValidationErrorData, http_res
454
425
  )
455
- raise models.HTTPValidationError(data=response_data)
426
+ raise errors.HTTPValidationError(response_data, http_res)
456
427
  if utils.match_response(http_res, "4XX", "*"):
457
428
  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
- )
429
+ raise errors.APIError("API error occurred", http_res, http_res_text)
461
430
  if utils.match_response(http_res, "5XX", "*"):
462
431
  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
- )
432
+ raise errors.APIError("API error occurred", http_res, http_res_text)
466
433
 
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
- )
434
+ raise errors.APIError("Unexpected response received", http_res)
475
435
 
476
436
  def update(
477
437
  self,
@@ -552,31 +512,22 @@ class DataSources(BaseSDK):
552
512
 
553
513
  response_data: Any = None
554
514
  if utils.match_response(http_res, "200", "application/json"):
555
- return utils.unmarshal_json(http_res.text, models.DataSourceDetailResponse)
515
+ return utils.unmarshal_json_response(
516
+ models.DataSourceDetailResponse, http_res
517
+ )
556
518
  if utils.match_response(http_res, "422", "application/json"):
557
- response_data = utils.unmarshal_json(
558
- http_res.text, models.HTTPValidationErrorData
519
+ response_data = utils.unmarshal_json_response(
520
+ errors.HTTPValidationErrorData, http_res
559
521
  )
560
- raise models.HTTPValidationError(data=response_data)
522
+ raise errors.HTTPValidationError(response_data, http_res)
561
523
  if utils.match_response(http_res, "4XX", "*"):
562
524
  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
- )
525
+ raise errors.APIError("API error occurred", http_res, http_res_text)
566
526
  if utils.match_response(http_res, "5XX", "*"):
567
527
  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
- )
528
+ raise errors.APIError("API error occurred", http_res, http_res_text)
571
529
 
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
- )
530
+ raise errors.APIError("Unexpected response received", http_res)
580
531
 
581
532
  async def update_async(
582
533
  self,
@@ -657,31 +608,22 @@ class DataSources(BaseSDK):
657
608
 
658
609
  response_data: Any = None
659
610
  if utils.match_response(http_res, "200", "application/json"):
660
- return utils.unmarshal_json(http_res.text, models.DataSourceDetailResponse)
611
+ return utils.unmarshal_json_response(
612
+ models.DataSourceDetailResponse, http_res
613
+ )
661
614
  if utils.match_response(http_res, "422", "application/json"):
662
- response_data = utils.unmarshal_json(
663
- http_res.text, models.HTTPValidationErrorData
615
+ response_data = utils.unmarshal_json_response(
616
+ errors.HTTPValidationErrorData, http_res
664
617
  )
665
- raise models.HTTPValidationError(data=response_data)
618
+ raise errors.HTTPValidationError(response_data, http_res)
666
619
  if utils.match_response(http_res, "4XX", "*"):
667
620
  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
- )
621
+ raise errors.APIError("API error occurred", http_res, http_res_text)
671
622
  if utils.match_response(http_res, "5XX", "*"):
672
623
  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
- )
624
+ raise errors.APIError("API error occurred", http_res, http_res_text)
676
625
 
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
- )
626
+ raise errors.APIError("Unexpected response received", http_res)
685
627
 
686
628
  def get_by_id(
687
629
  self,
@@ -757,31 +699,22 @@ class DataSources(BaseSDK):
757
699
 
758
700
  response_data: Any = None
759
701
  if utils.match_response(http_res, "200", "application/json"):
760
- return utils.unmarshal_json(http_res.text, models.DataSourceDetailResponse)
702
+ return utils.unmarshal_json_response(
703
+ models.DataSourceDetailResponse, http_res
704
+ )
761
705
  if utils.match_response(http_res, "422", "application/json"):
762
- response_data = utils.unmarshal_json(
763
- http_res.text, models.HTTPValidationErrorData
706
+ response_data = utils.unmarshal_json_response(
707
+ errors.HTTPValidationErrorData, http_res
764
708
  )
765
- raise models.HTTPValidationError(data=response_data)
709
+ raise errors.HTTPValidationError(response_data, http_res)
766
710
  if utils.match_response(http_res, "4XX", "*"):
767
711
  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
- )
712
+ raise errors.APIError("API error occurred", http_res, http_res_text)
771
713
  if utils.match_response(http_res, "5XX", "*"):
772
714
  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
- )
715
+ raise errors.APIError("API error occurred", http_res, http_res_text)
776
716
 
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
- )
717
+ raise errors.APIError("Unexpected response received", http_res)
785
718
 
786
719
  async def get_by_id_async(
787
720
  self,
@@ -857,31 +790,22 @@ class DataSources(BaseSDK):
857
790
 
858
791
  response_data: Any = None
859
792
  if utils.match_response(http_res, "200", "application/json"):
860
- return utils.unmarshal_json(http_res.text, models.DataSourceDetailResponse)
793
+ return utils.unmarshal_json_response(
794
+ models.DataSourceDetailResponse, http_res
795
+ )
861
796
  if utils.match_response(http_res, "422", "application/json"):
862
- response_data = utils.unmarshal_json(
863
- http_res.text, models.HTTPValidationErrorData
797
+ response_data = utils.unmarshal_json_response(
798
+ errors.HTTPValidationErrorData, http_res
864
799
  )
865
- raise models.HTTPValidationError(data=response_data)
800
+ raise errors.HTTPValidationError(response_data, http_res)
866
801
  if utils.match_response(http_res, "4XX", "*"):
867
802
  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
- )
803
+ raise errors.APIError("API error occurred", http_res, http_res_text)
871
804
  if utils.match_response(http_res, "5XX", "*"):
872
805
  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
- )
806
+ raise errors.APIError("API error occurred", http_res, http_res_text)
876
807
 
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
- )
808
+ raise errors.APIError("Unexpected response received", http_res)
885
809
 
886
810
  def delete(
887
811
  self,
@@ -960,31 +884,20 @@ class DataSources(BaseSDK):
960
884
 
961
885
  response_data: Any = None
962
886
  if utils.match_response(http_res, "200", "application/json"):
963
- return utils.unmarshal_json(http_res.text, Any)
887
+ return utils.unmarshal_json_response(Any, http_res)
964
888
  if utils.match_response(http_res, "422", "application/json"):
965
- response_data = utils.unmarshal_json(
966
- http_res.text, models.HTTPValidationErrorData
889
+ response_data = utils.unmarshal_json_response(
890
+ errors.HTTPValidationErrorData, http_res
967
891
  )
968
- raise models.HTTPValidationError(data=response_data)
892
+ raise errors.HTTPValidationError(response_data, http_res)
969
893
  if utils.match_response(http_res, "4XX", "*"):
970
894
  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
- )
895
+ raise errors.APIError("API error occurred", http_res, http_res_text)
974
896
  if utils.match_response(http_res, "5XX", "*"):
975
897
  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
- )
898
+ raise errors.APIError("API error occurred", http_res, http_res_text)
979
899
 
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
- )
900
+ raise errors.APIError("Unexpected response received", http_res)
988
901
 
989
902
  async def delete_async(
990
903
  self,
@@ -1063,28 +976,17 @@ class DataSources(BaseSDK):
1063
976
 
1064
977
  response_data: Any = None
1065
978
  if utils.match_response(http_res, "200", "application/json"):
1066
- return utils.unmarshal_json(http_res.text, Any)
979
+ return utils.unmarshal_json_response(Any, http_res)
1067
980
  if utils.match_response(http_res, "422", "application/json"):
1068
- response_data = utils.unmarshal_json(
1069
- http_res.text, models.HTTPValidationErrorData
981
+ response_data = utils.unmarshal_json_response(
982
+ errors.HTTPValidationErrorData, http_res
1070
983
  )
1071
- raise models.HTTPValidationError(data=response_data)
984
+ raise errors.HTTPValidationError(response_data, http_res)
1072
985
  if utils.match_response(http_res, "4XX", "*"):
1073
986
  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
- )
987
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1077
988
  if utils.match_response(http_res, "5XX", "*"):
1078
989
  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
- )
990
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1082
991
 
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
- )
992
+ raise errors.APIError("Unexpected response received", http_res)
@@ -0,0 +1,55 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from typing import TYPE_CHECKING
4
+ from importlib import import_module
5
+
6
+ if TYPE_CHECKING:
7
+ from .apierror import APIError
8
+ from .httpvalidationerror import HTTPValidationError, HTTPValidationErrorData
9
+ from .no_response_error import NoResponseError
10
+ from .responsevalidationerror import ResponseValidationError
11
+ from .syllablesdkerror import SyllableSDKError
12
+
13
+ __all__ = [
14
+ "APIError",
15
+ "HTTPValidationError",
16
+ "HTTPValidationErrorData",
17
+ "NoResponseError",
18
+ "ResponseValidationError",
19
+ "SyllableSDKError",
20
+ ]
21
+
22
+ _dynamic_imports: dict[str, str] = {
23
+ "APIError": ".apierror",
24
+ "HTTPValidationError": ".httpvalidationerror",
25
+ "HTTPValidationErrorData": ".httpvalidationerror",
26
+ "NoResponseError": ".no_response_error",
27
+ "ResponseValidationError": ".responsevalidationerror",
28
+ "SyllableSDKError": ".syllablesdkerror",
29
+ }
30
+
31
+
32
+ def __getattr__(attr_name: str) -> object:
33
+ module_name = _dynamic_imports.get(attr_name)
34
+ if module_name is None:
35
+ raise AttributeError(
36
+ f"No {attr_name} found in _dynamic_imports for module name -> {__name__} "
37
+ )
38
+
39
+ try:
40
+ module = import_module(module_name, __package__)
41
+ result = getattr(module, attr_name)
42
+ return result
43
+ except ImportError as e:
44
+ raise ImportError(
45
+ f"Failed to import {attr_name} from {module_name}: {e}"
46
+ ) from e
47
+ except AttributeError as e:
48
+ raise AttributeError(
49
+ f"Failed to get {attr_name} from {module_name}: {e}"
50
+ ) from e
51
+
52
+
53
+ def __dir__():
54
+ lazy_attrs = list(_dynamic_imports.keys())
55
+ return sorted(lazy_attrs)
@@ -0,0 +1,38 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ import httpx
4
+ from typing import Optional
5
+
6
+ from syllable_sdk.errors import SyllableSDKError
7
+
8
+ MAX_MESSAGE_LEN = 10_000
9
+
10
+
11
+ class APIError(SyllableSDKError):
12
+ """The fallback error class if no more specific error class is matched."""
13
+
14
+ def __init__(
15
+ self, message: str, raw_response: httpx.Response, body: Optional[str] = None
16
+ ):
17
+ body_display = body or raw_response.text or '""'
18
+
19
+ if message:
20
+ message += ": "
21
+ message += f"Status {raw_response.status_code}"
22
+
23
+ headers = raw_response.headers
24
+ content_type = headers.get("content-type", '""')
25
+ if content_type != "application/json":
26
+ if " " in content_type:
27
+ content_type = f'"{content_type}"'
28
+ message += f" Content-Type {content_type}"
29
+
30
+ if len(body_display) > MAX_MESSAGE_LEN:
31
+ truncated = body_display[:MAX_MESSAGE_LEN]
32
+ remaining = len(body_display) - MAX_MESSAGE_LEN
33
+ body_display = f"{truncated}...and {remaining} more chars"
34
+
35
+ message += f". Body: {body_display}"
36
+ message = message.strip()
37
+
38
+ super().__init__(message, raw_response, body)
@@ -0,0 +1,26 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ import httpx
5
+ from syllable_sdk.errors import SyllableSDKError
6
+ from syllable_sdk.models import validationerror as models_validationerror
7
+ from syllable_sdk.types import BaseModel
8
+ from typing import List, Optional
9
+
10
+
11
+ class HTTPValidationErrorData(BaseModel):
12
+ detail: Optional[List[models_validationerror.ValidationError]] = None
13
+
14
+
15
+ class HTTPValidationError(SyllableSDKError):
16
+ data: HTTPValidationErrorData
17
+
18
+ def __init__(
19
+ self,
20
+ data: HTTPValidationErrorData,
21
+ raw_response: httpx.Response,
22
+ body: Optional[str] = None,
23
+ ):
24
+ message = body or raw_response.text
25
+ super().__init__(message, raw_response, body)
26
+ self.data = data
@@ -0,0 +1,13 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ class NoResponseError(Exception):
4
+ """Error raised when no HTTP response is received from the server."""
5
+
6
+ message: str
7
+
8
+ def __init__(self, message: str = "No response received"):
9
+ self.message = message
10
+ super().__init__(message)
11
+
12
+ def __str__(self):
13
+ return self.message
@@ -0,0 +1,25 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ import httpx
4
+ from typing import Optional
5
+
6
+ from syllable_sdk.errors import SyllableSDKError
7
+
8
+
9
+ class ResponseValidationError(SyllableSDKError):
10
+ """Error raised when there is a type mismatch between the response data and the expected Pydantic model."""
11
+
12
+ def __init__(
13
+ self,
14
+ message: str,
15
+ raw_response: httpx.Response,
16
+ cause: Exception,
17
+ body: Optional[str] = None,
18
+ ):
19
+ message = f"{message}: {cause}"
20
+ super().__init__(message, raw_response, body)
21
+
22
+ @property
23
+ def cause(self):
24
+ """Normally the Pydantic ValidationError"""
25
+ return self.__cause__
@@ -0,0 +1,26 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ import httpx
4
+ from typing import Optional
5
+
6
+
7
+ class SyllableSDKError(Exception):
8
+ """The base class for all HTTP error responses."""
9
+
10
+ message: str
11
+ status_code: int
12
+ body: str
13
+ headers: httpx.Headers
14
+ raw_response: httpx.Response
15
+
16
+ def __init__(
17
+ self, message: str, raw_response: httpx.Response, body: Optional[str] = None
18
+ ):
19
+ self.message = message
20
+ self.status_code = raw_response.status_code
21
+ self.body = body if body is not None else raw_response.text
22
+ self.headers = raw_response.headers
23
+ self.raw_response = raw_response
24
+
25
+ def __str__(self):
26
+ return self.message