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
@@ -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 DataSources(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.ListResponseDataSourceMetadataResponse
113
+ return unmarshal_json_response(
114
+ models.ListResponseDataSourceMetadataResponse, 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 DataSources(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.ListResponseDataSourceMetadataResponse
228
+ return unmarshal_json_response(
229
+ models.ListResponseDataSourceMetadataResponse, 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 DataSources(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.DataSourceDetailResponse)
324
+ return unmarshal_json_response(models.DataSourceDetailResponse, 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 DataSources(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.DataSourceDetailResponse)
418
+ return unmarshal_json_response(models.DataSourceDetailResponse, 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 update(
477
434
  self,
@@ -552,31 +509,20 @@ class DataSources(BaseSDK):
552
509
 
553
510
  response_data: Any = None
554
511
  if utils.match_response(http_res, "200", "application/json"):
555
- return utils.unmarshal_json(http_res.text, models.DataSourceDetailResponse)
512
+ return unmarshal_json_response(models.DataSourceDetailResponse, http_res)
556
513
  if utils.match_response(http_res, "422", "application/json"):
557
- response_data = utils.unmarshal_json(
558
- http_res.text, models.HTTPValidationErrorData
514
+ response_data = unmarshal_json_response(
515
+ errors.HTTPValidationErrorData, http_res
559
516
  )
560
- raise models.HTTPValidationError(data=response_data)
517
+ raise errors.HTTPValidationError(response_data, http_res)
561
518
  if utils.match_response(http_res, "4XX", "*"):
562
519
  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
- )
520
+ raise errors.APIError("API error occurred", http_res, http_res_text)
566
521
  if utils.match_response(http_res, "5XX", "*"):
567
522
  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
- )
523
+ raise errors.APIError("API error occurred", http_res, http_res_text)
571
524
 
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
- )
525
+ raise errors.APIError("Unexpected response received", http_res)
580
526
 
581
527
  async def update_async(
582
528
  self,
@@ -657,31 +603,20 @@ class DataSources(BaseSDK):
657
603
 
658
604
  response_data: Any = None
659
605
  if utils.match_response(http_res, "200", "application/json"):
660
- return utils.unmarshal_json(http_res.text, models.DataSourceDetailResponse)
606
+ return unmarshal_json_response(models.DataSourceDetailResponse, http_res)
661
607
  if utils.match_response(http_res, "422", "application/json"):
662
- response_data = utils.unmarshal_json(
663
- http_res.text, models.HTTPValidationErrorData
608
+ response_data = unmarshal_json_response(
609
+ errors.HTTPValidationErrorData, http_res
664
610
  )
665
- raise models.HTTPValidationError(data=response_data)
611
+ raise errors.HTTPValidationError(response_data, http_res)
666
612
  if utils.match_response(http_res, "4XX", "*"):
667
613
  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
- )
614
+ raise errors.APIError("API error occurred", http_res, http_res_text)
671
615
  if utils.match_response(http_res, "5XX", "*"):
672
616
  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
- )
617
+ raise errors.APIError("API error occurred", http_res, http_res_text)
676
618
 
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
- )
619
+ raise errors.APIError("Unexpected response received", http_res)
685
620
 
686
621
  def get_by_id(
687
622
  self,
@@ -757,31 +692,20 @@ class DataSources(BaseSDK):
757
692
 
758
693
  response_data: Any = None
759
694
  if utils.match_response(http_res, "200", "application/json"):
760
- return utils.unmarshal_json(http_res.text, models.DataSourceDetailResponse)
695
+ return unmarshal_json_response(models.DataSourceDetailResponse, http_res)
761
696
  if utils.match_response(http_res, "422", "application/json"):
762
- response_data = utils.unmarshal_json(
763
- http_res.text, models.HTTPValidationErrorData
697
+ response_data = unmarshal_json_response(
698
+ errors.HTTPValidationErrorData, http_res
764
699
  )
765
- raise models.HTTPValidationError(data=response_data)
700
+ raise errors.HTTPValidationError(response_data, http_res)
766
701
  if utils.match_response(http_res, "4XX", "*"):
767
702
  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
- )
703
+ raise errors.APIError("API error occurred", http_res, http_res_text)
771
704
  if utils.match_response(http_res, "5XX", "*"):
772
705
  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
- )
706
+ raise errors.APIError("API error occurred", http_res, http_res_text)
776
707
 
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
- )
708
+ raise errors.APIError("Unexpected response received", http_res)
785
709
 
786
710
  async def get_by_id_async(
787
711
  self,
@@ -857,31 +781,20 @@ class DataSources(BaseSDK):
857
781
 
858
782
  response_data: Any = None
859
783
  if utils.match_response(http_res, "200", "application/json"):
860
- return utils.unmarshal_json(http_res.text, models.DataSourceDetailResponse)
784
+ return unmarshal_json_response(models.DataSourceDetailResponse, http_res)
861
785
  if utils.match_response(http_res, "422", "application/json"):
862
- response_data = utils.unmarshal_json(
863
- http_res.text, models.HTTPValidationErrorData
786
+ response_data = unmarshal_json_response(
787
+ errors.HTTPValidationErrorData, http_res
864
788
  )
865
- raise models.HTTPValidationError(data=response_data)
789
+ raise errors.HTTPValidationError(response_data, http_res)
866
790
  if utils.match_response(http_res, "4XX", "*"):
867
791
  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
- )
792
+ raise errors.APIError("API error occurred", http_res, http_res_text)
871
793
  if utils.match_response(http_res, "5XX", "*"):
872
794
  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
- )
795
+ raise errors.APIError("API error occurred", http_res, http_res_text)
876
796
 
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
- )
797
+ raise errors.APIError("Unexpected response received", http_res)
885
798
 
886
799
  def delete(
887
800
  self,
@@ -960,31 +873,20 @@ class DataSources(BaseSDK):
960
873
 
961
874
  response_data: Any = None
962
875
  if utils.match_response(http_res, "200", "application/json"):
963
- return utils.unmarshal_json(http_res.text, Any)
876
+ return unmarshal_json_response(Any, http_res)
964
877
  if utils.match_response(http_res, "422", "application/json"):
965
- response_data = utils.unmarshal_json(
966
- http_res.text, models.HTTPValidationErrorData
878
+ response_data = unmarshal_json_response(
879
+ errors.HTTPValidationErrorData, http_res
967
880
  )
968
- raise models.HTTPValidationError(data=response_data)
881
+ raise errors.HTTPValidationError(response_data, http_res)
969
882
  if utils.match_response(http_res, "4XX", "*"):
970
883
  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
- )
884
+ raise errors.APIError("API error occurred", http_res, http_res_text)
974
885
  if utils.match_response(http_res, "5XX", "*"):
975
886
  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
- )
887
+ raise errors.APIError("API error occurred", http_res, http_res_text)
979
888
 
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
- )
889
+ raise errors.APIError("Unexpected response received", http_res)
988
890
 
989
891
  async def delete_async(
990
892
  self,
@@ -1063,28 +965,17 @@ class DataSources(BaseSDK):
1063
965
 
1064
966
  response_data: Any = None
1065
967
  if utils.match_response(http_res, "200", "application/json"):
1066
- return utils.unmarshal_json(http_res.text, Any)
968
+ return unmarshal_json_response(Any, http_res)
1067
969
  if utils.match_response(http_res, "422", "application/json"):
1068
- response_data = utils.unmarshal_json(
1069
- http_res.text, models.HTTPValidationErrorData
970
+ response_data = unmarshal_json_response(
971
+ errors.HTTPValidationErrorData, http_res
1070
972
  )
1071
- raise models.HTTPValidationError(data=response_data)
973
+ raise errors.HTTPValidationError(response_data, http_res)
1072
974
  if utils.match_response(http_res, "4XX", "*"):
1073
975
  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
- )
976
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1077
977
  if utils.match_response(http_res, "5XX", "*"):
1078
978
  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
- )
979
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1082
980
 
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
- )
981
+ 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