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.
- syllable_sdk/__init__.py +0 -1
- syllable_sdk/_version.py +3 -3
- syllable_sdk/agents.py +83 -211
- syllable_sdk/basesdk.py +5 -5
- syllable_sdk/batches.py +131 -329
- syllable_sdk/campaigns.py +73 -183
- syllable_sdk/channels.py +29 -73
- syllable_sdk/conversations.py +19 -37
- syllable_sdk/custom_messages.py +73 -183
- syllable_sdk/dashboards.py +67 -195
- syllable_sdk/data_sources.py +85 -183
- syllable_sdk/errors/__init__.py +55 -0
- syllable_sdk/errors/apierror.py +38 -0
- syllable_sdk/errors/httpvalidationerror.py +26 -0
- syllable_sdk/errors/no_response_error.py +13 -0
- syllable_sdk/errors/responsevalidationerror.py +25 -0
- syllable_sdk/errors/syllablesdkerror.py +26 -0
- syllable_sdk/events.py +15 -37
- syllable_sdk/folders.py +121 -293
- syllable_sdk/full_summary.py +19 -37
- syllable_sdk/incidents.py +83 -215
- syllable_sdk/insights_sdk.py +17 -39
- syllable_sdk/insights_tools.py +97 -251
- syllable_sdk/language_groups.py +85 -215
- syllable_sdk/latency.py +19 -37
- syllable_sdk/models/__init__.py +0 -8
- syllable_sdk/numbers.py +53 -111
- syllable_sdk/organizations.py +51 -139
- syllable_sdk/permissions.py +11 -33
- syllable_sdk/prompts.py +95 -249
- syllable_sdk/roles.py +75 -181
- syllable_sdk/services.py +73 -183
- syllable_sdk/session_debug.py +43 -109
- syllable_sdk/session_labels.py +47 -109
- syllable_sdk/sessions.py +59 -141
- syllable_sdk/takeouts.py +35 -99
- syllable_sdk/targets.py +75 -185
- syllable_sdk/test.py +15 -37
- syllable_sdk/tools.py +75 -181
- syllable_sdk/transcript.py +17 -39
- syllable_sdk/twilio.py +43 -109
- syllable_sdk/users.py +97 -247
- syllable_sdk/utils/__init__.py +3 -0
- syllable_sdk/utils/serializers.py +21 -3
- syllable_sdk/v1.py +97 -247
- syllable_sdk/workflows.py +115 -291
- {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/METADATA +58 -45
- {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/RECORD +49 -45
- syllable_sdk/models/apierror.py +0 -22
- syllable_sdk/models/httpvalidationerror.py +0 -21
- {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/WHEEL +0 -0
syllable_sdk/users.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
|
|
@@ -107,31 +107,22 @@ class Users(BaseSDK):
|
|
|
107
107
|
|
|
108
108
|
response_data: Any = None
|
|
109
109
|
if utils.match_response(http_res, "200", "application/json"):
|
|
110
|
-
return utils.
|
|
110
|
+
return utils.unmarshal_json_response(
|
|
111
|
+
models.ListResponseUserResponse, http_res
|
|
112
|
+
)
|
|
111
113
|
if utils.match_response(http_res, "422", "application/json"):
|
|
112
|
-
response_data = utils.
|
|
113
|
-
|
|
114
|
+
response_data = utils.unmarshal_json_response(
|
|
115
|
+
errors.HTTPValidationErrorData, http_res
|
|
114
116
|
)
|
|
115
|
-
raise
|
|
117
|
+
raise errors.HTTPValidationError(response_data, http_res)
|
|
116
118
|
if utils.match_response(http_res, "4XX", "*"):
|
|
117
119
|
http_res_text = utils.stream_to_text(http_res)
|
|
118
|
-
raise
|
|
119
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
120
|
-
)
|
|
120
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
121
121
|
if utils.match_response(http_res, "5XX", "*"):
|
|
122
122
|
http_res_text = utils.stream_to_text(http_res)
|
|
123
|
-
raise
|
|
124
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
125
|
-
)
|
|
123
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
126
124
|
|
|
127
|
-
|
|
128
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
129
|
-
raise models.APIError(
|
|
130
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
131
|
-
http_res.status_code,
|
|
132
|
-
http_res_text,
|
|
133
|
-
http_res,
|
|
134
|
-
)
|
|
125
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
135
126
|
|
|
136
127
|
async def list_async(
|
|
137
128
|
self,
|
|
@@ -231,31 +222,22 @@ class Users(BaseSDK):
|
|
|
231
222
|
|
|
232
223
|
response_data: Any = None
|
|
233
224
|
if utils.match_response(http_res, "200", "application/json"):
|
|
234
|
-
return utils.
|
|
225
|
+
return utils.unmarshal_json_response(
|
|
226
|
+
models.ListResponseUserResponse, http_res
|
|
227
|
+
)
|
|
235
228
|
if utils.match_response(http_res, "422", "application/json"):
|
|
236
|
-
response_data = utils.
|
|
237
|
-
|
|
229
|
+
response_data = utils.unmarshal_json_response(
|
|
230
|
+
errors.HTTPValidationErrorData, http_res
|
|
238
231
|
)
|
|
239
|
-
raise
|
|
232
|
+
raise errors.HTTPValidationError(response_data, http_res)
|
|
240
233
|
if utils.match_response(http_res, "4XX", "*"):
|
|
241
234
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
242
|
-
raise
|
|
243
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
244
|
-
)
|
|
235
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
245
236
|
if utils.match_response(http_res, "5XX", "*"):
|
|
246
237
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
247
|
-
raise
|
|
248
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
249
|
-
)
|
|
238
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
250
239
|
|
|
251
|
-
|
|
252
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
253
|
-
raise models.APIError(
|
|
254
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
255
|
-
http_res.status_code,
|
|
256
|
-
http_res_text,
|
|
257
|
-
http_res,
|
|
258
|
-
)
|
|
240
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
259
241
|
|
|
260
242
|
def create(
|
|
261
243
|
self,
|
|
@@ -334,31 +316,20 @@ class Users(BaseSDK):
|
|
|
334
316
|
|
|
335
317
|
response_data: Any = None
|
|
336
318
|
if utils.match_response(http_res, "200", "application/json"):
|
|
337
|
-
return utils.
|
|
319
|
+
return utils.unmarshal_json_response(models.UserResponse, http_res)
|
|
338
320
|
if utils.match_response(http_res, "422", "application/json"):
|
|
339
|
-
response_data = utils.
|
|
340
|
-
|
|
321
|
+
response_data = utils.unmarshal_json_response(
|
|
322
|
+
errors.HTTPValidationErrorData, http_res
|
|
341
323
|
)
|
|
342
|
-
raise
|
|
324
|
+
raise errors.HTTPValidationError(response_data, http_res)
|
|
343
325
|
if utils.match_response(http_res, "4XX", "*"):
|
|
344
326
|
http_res_text = utils.stream_to_text(http_res)
|
|
345
|
-
raise
|
|
346
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
347
|
-
)
|
|
327
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
348
328
|
if utils.match_response(http_res, "5XX", "*"):
|
|
349
329
|
http_res_text = utils.stream_to_text(http_res)
|
|
350
|
-
raise
|
|
351
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
352
|
-
)
|
|
330
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
353
331
|
|
|
354
|
-
|
|
355
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
356
|
-
raise models.APIError(
|
|
357
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
358
|
-
http_res.status_code,
|
|
359
|
-
http_res_text,
|
|
360
|
-
http_res,
|
|
361
|
-
)
|
|
332
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
362
333
|
|
|
363
334
|
async def create_async(
|
|
364
335
|
self,
|
|
@@ -437,31 +408,20 @@ class Users(BaseSDK):
|
|
|
437
408
|
|
|
438
409
|
response_data: Any = None
|
|
439
410
|
if utils.match_response(http_res, "200", "application/json"):
|
|
440
|
-
return utils.
|
|
411
|
+
return utils.unmarshal_json_response(models.UserResponse, http_res)
|
|
441
412
|
if utils.match_response(http_res, "422", "application/json"):
|
|
442
|
-
response_data = utils.
|
|
443
|
-
|
|
413
|
+
response_data = utils.unmarshal_json_response(
|
|
414
|
+
errors.HTTPValidationErrorData, http_res
|
|
444
415
|
)
|
|
445
|
-
raise
|
|
416
|
+
raise errors.HTTPValidationError(response_data, http_res)
|
|
446
417
|
if utils.match_response(http_res, "4XX", "*"):
|
|
447
418
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
448
|
-
raise
|
|
449
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
450
|
-
)
|
|
419
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
451
420
|
if utils.match_response(http_res, "5XX", "*"):
|
|
452
421
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
453
|
-
raise
|
|
454
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
455
|
-
)
|
|
422
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
456
423
|
|
|
457
|
-
|
|
458
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
459
|
-
raise models.APIError(
|
|
460
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
461
|
-
http_res.status_code,
|
|
462
|
-
http_res_text,
|
|
463
|
-
http_res,
|
|
464
|
-
)
|
|
424
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
465
425
|
|
|
466
426
|
def update(
|
|
467
427
|
self,
|
|
@@ -540,31 +500,20 @@ class Users(BaseSDK):
|
|
|
540
500
|
|
|
541
501
|
response_data: Any = None
|
|
542
502
|
if utils.match_response(http_res, "200", "application/json"):
|
|
543
|
-
return utils.
|
|
503
|
+
return utils.unmarshal_json_response(models.UserResponse, http_res)
|
|
544
504
|
if utils.match_response(http_res, "422", "application/json"):
|
|
545
|
-
response_data = utils.
|
|
546
|
-
|
|
505
|
+
response_data = utils.unmarshal_json_response(
|
|
506
|
+
errors.HTTPValidationErrorData, http_res
|
|
547
507
|
)
|
|
548
|
-
raise
|
|
508
|
+
raise errors.HTTPValidationError(response_data, http_res)
|
|
549
509
|
if utils.match_response(http_res, "4XX", "*"):
|
|
550
510
|
http_res_text = utils.stream_to_text(http_res)
|
|
551
|
-
raise
|
|
552
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
553
|
-
)
|
|
511
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
554
512
|
if utils.match_response(http_res, "5XX", "*"):
|
|
555
513
|
http_res_text = utils.stream_to_text(http_res)
|
|
556
|
-
raise
|
|
557
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
558
|
-
)
|
|
514
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
559
515
|
|
|
560
|
-
|
|
561
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
562
|
-
raise models.APIError(
|
|
563
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
564
|
-
http_res.status_code,
|
|
565
|
-
http_res_text,
|
|
566
|
-
http_res,
|
|
567
|
-
)
|
|
516
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
568
517
|
|
|
569
518
|
async def update_async(
|
|
570
519
|
self,
|
|
@@ -643,31 +592,20 @@ class Users(BaseSDK):
|
|
|
643
592
|
|
|
644
593
|
response_data: Any = None
|
|
645
594
|
if utils.match_response(http_res, "200", "application/json"):
|
|
646
|
-
return utils.
|
|
595
|
+
return utils.unmarshal_json_response(models.UserResponse, http_res)
|
|
647
596
|
if utils.match_response(http_res, "422", "application/json"):
|
|
648
|
-
response_data = utils.
|
|
649
|
-
|
|
597
|
+
response_data = utils.unmarshal_json_response(
|
|
598
|
+
errors.HTTPValidationErrorData, http_res
|
|
650
599
|
)
|
|
651
|
-
raise
|
|
600
|
+
raise errors.HTTPValidationError(response_data, http_res)
|
|
652
601
|
if utils.match_response(http_res, "4XX", "*"):
|
|
653
602
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
654
|
-
raise
|
|
655
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
656
|
-
)
|
|
603
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
657
604
|
if utils.match_response(http_res, "5XX", "*"):
|
|
658
605
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
659
|
-
raise
|
|
660
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
661
|
-
)
|
|
606
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
662
607
|
|
|
663
|
-
|
|
664
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
665
|
-
raise models.APIError(
|
|
666
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
667
|
-
http_res.status_code,
|
|
668
|
-
http_res_text,
|
|
669
|
-
http_res,
|
|
670
|
-
)
|
|
608
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
671
609
|
|
|
672
610
|
def delete(
|
|
673
611
|
self,
|
|
@@ -746,31 +684,20 @@ class Users(BaseSDK):
|
|
|
746
684
|
|
|
747
685
|
response_data: Any = None
|
|
748
686
|
if utils.match_response(http_res, "200", "application/json"):
|
|
749
|
-
return utils.
|
|
687
|
+
return utils.unmarshal_json_response(Any, http_res)
|
|
750
688
|
if utils.match_response(http_res, "422", "application/json"):
|
|
751
|
-
response_data = utils.
|
|
752
|
-
|
|
689
|
+
response_data = utils.unmarshal_json_response(
|
|
690
|
+
errors.HTTPValidationErrorData, http_res
|
|
753
691
|
)
|
|
754
|
-
raise
|
|
692
|
+
raise errors.HTTPValidationError(response_data, http_res)
|
|
755
693
|
if utils.match_response(http_res, "4XX", "*"):
|
|
756
694
|
http_res_text = utils.stream_to_text(http_res)
|
|
757
|
-
raise
|
|
758
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
759
|
-
)
|
|
695
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
760
696
|
if utils.match_response(http_res, "5XX", "*"):
|
|
761
697
|
http_res_text = utils.stream_to_text(http_res)
|
|
762
|
-
raise
|
|
763
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
764
|
-
)
|
|
698
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
765
699
|
|
|
766
|
-
|
|
767
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
768
|
-
raise models.APIError(
|
|
769
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
770
|
-
http_res.status_code,
|
|
771
|
-
http_res_text,
|
|
772
|
-
http_res,
|
|
773
|
-
)
|
|
700
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
774
701
|
|
|
775
702
|
async def delete_async(
|
|
776
703
|
self,
|
|
@@ -849,31 +776,20 @@ class Users(BaseSDK):
|
|
|
849
776
|
|
|
850
777
|
response_data: Any = None
|
|
851
778
|
if utils.match_response(http_res, "200", "application/json"):
|
|
852
|
-
return utils.
|
|
779
|
+
return utils.unmarshal_json_response(Any, http_res)
|
|
853
780
|
if utils.match_response(http_res, "422", "application/json"):
|
|
854
|
-
response_data = utils.
|
|
855
|
-
|
|
781
|
+
response_data = utils.unmarshal_json_response(
|
|
782
|
+
errors.HTTPValidationErrorData, http_res
|
|
856
783
|
)
|
|
857
|
-
raise
|
|
784
|
+
raise errors.HTTPValidationError(response_data, http_res)
|
|
858
785
|
if utils.match_response(http_res, "4XX", "*"):
|
|
859
786
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
860
|
-
raise
|
|
861
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
862
|
-
)
|
|
787
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
863
788
|
if utils.match_response(http_res, "5XX", "*"):
|
|
864
789
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
865
|
-
raise
|
|
866
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
867
|
-
)
|
|
790
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
868
791
|
|
|
869
|
-
|
|
870
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
871
|
-
raise models.APIError(
|
|
872
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
873
|
-
http_res.status_code,
|
|
874
|
-
http_res_text,
|
|
875
|
-
http_res,
|
|
876
|
-
)
|
|
792
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
877
793
|
|
|
878
794
|
def users_get_by_email(
|
|
879
795
|
self,
|
|
@@ -949,31 +865,20 @@ class Users(BaseSDK):
|
|
|
949
865
|
|
|
950
866
|
response_data: Any = None
|
|
951
867
|
if utils.match_response(http_res, "200", "application/json"):
|
|
952
|
-
return utils.
|
|
868
|
+
return utils.unmarshal_json_response(models.UserResponse, http_res)
|
|
953
869
|
if utils.match_response(http_res, "422", "application/json"):
|
|
954
|
-
response_data = utils.
|
|
955
|
-
|
|
870
|
+
response_data = utils.unmarshal_json_response(
|
|
871
|
+
errors.HTTPValidationErrorData, http_res
|
|
956
872
|
)
|
|
957
|
-
raise
|
|
873
|
+
raise errors.HTTPValidationError(response_data, http_res)
|
|
958
874
|
if utils.match_response(http_res, "4XX", "*"):
|
|
959
875
|
http_res_text = utils.stream_to_text(http_res)
|
|
960
|
-
raise
|
|
961
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
962
|
-
)
|
|
876
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
963
877
|
if utils.match_response(http_res, "5XX", "*"):
|
|
964
878
|
http_res_text = utils.stream_to_text(http_res)
|
|
965
|
-
raise
|
|
966
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
967
|
-
)
|
|
879
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
968
880
|
|
|
969
|
-
|
|
970
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
971
|
-
raise models.APIError(
|
|
972
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
973
|
-
http_res.status_code,
|
|
974
|
-
http_res_text,
|
|
975
|
-
http_res,
|
|
976
|
-
)
|
|
881
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
977
882
|
|
|
978
883
|
async def users_get_by_email_async(
|
|
979
884
|
self,
|
|
@@ -1049,31 +954,20 @@ class Users(BaseSDK):
|
|
|
1049
954
|
|
|
1050
955
|
response_data: Any = None
|
|
1051
956
|
if utils.match_response(http_res, "200", "application/json"):
|
|
1052
|
-
return utils.
|
|
957
|
+
return utils.unmarshal_json_response(models.UserResponse, http_res)
|
|
1053
958
|
if utils.match_response(http_res, "422", "application/json"):
|
|
1054
|
-
response_data = utils.
|
|
1055
|
-
|
|
959
|
+
response_data = utils.unmarshal_json_response(
|
|
960
|
+
errors.HTTPValidationErrorData, http_res
|
|
1056
961
|
)
|
|
1057
|
-
raise
|
|
962
|
+
raise errors.HTTPValidationError(response_data, http_res)
|
|
1058
963
|
if utils.match_response(http_res, "4XX", "*"):
|
|
1059
964
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1060
|
-
raise
|
|
1061
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1062
|
-
)
|
|
965
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1063
966
|
if utils.match_response(http_res, "5XX", "*"):
|
|
1064
967
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1065
|
-
raise
|
|
1066
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1067
|
-
)
|
|
968
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1068
969
|
|
|
1069
|
-
|
|
1070
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1071
|
-
raise models.APIError(
|
|
1072
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1073
|
-
http_res.status_code,
|
|
1074
|
-
http_res_text,
|
|
1075
|
-
http_res,
|
|
1076
|
-
)
|
|
970
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
1077
971
|
|
|
1078
972
|
def users_send_email(
|
|
1079
973
|
self,
|
|
@@ -1149,31 +1043,20 @@ class Users(BaseSDK):
|
|
|
1149
1043
|
|
|
1150
1044
|
response_data: Any = None
|
|
1151
1045
|
if utils.match_response(http_res, "200", "application/json"):
|
|
1152
|
-
return utils.
|
|
1046
|
+
return utils.unmarshal_json_response(Any, http_res)
|
|
1153
1047
|
if utils.match_response(http_res, "422", "application/json"):
|
|
1154
|
-
response_data = utils.
|
|
1155
|
-
|
|
1048
|
+
response_data = utils.unmarshal_json_response(
|
|
1049
|
+
errors.HTTPValidationErrorData, http_res
|
|
1156
1050
|
)
|
|
1157
|
-
raise
|
|
1051
|
+
raise errors.HTTPValidationError(response_data, http_res)
|
|
1158
1052
|
if utils.match_response(http_res, "4XX", "*"):
|
|
1159
1053
|
http_res_text = utils.stream_to_text(http_res)
|
|
1160
|
-
raise
|
|
1161
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1162
|
-
)
|
|
1054
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1163
1055
|
if utils.match_response(http_res, "5XX", "*"):
|
|
1164
1056
|
http_res_text = utils.stream_to_text(http_res)
|
|
1165
|
-
raise
|
|
1166
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1167
|
-
)
|
|
1057
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1168
1058
|
|
|
1169
|
-
|
|
1170
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
1171
|
-
raise models.APIError(
|
|
1172
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1173
|
-
http_res.status_code,
|
|
1174
|
-
http_res_text,
|
|
1175
|
-
http_res,
|
|
1176
|
-
)
|
|
1059
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
1177
1060
|
|
|
1178
1061
|
async def users_send_email_async(
|
|
1179
1062
|
self,
|
|
@@ -1249,31 +1132,20 @@ class Users(BaseSDK):
|
|
|
1249
1132
|
|
|
1250
1133
|
response_data: Any = None
|
|
1251
1134
|
if utils.match_response(http_res, "200", "application/json"):
|
|
1252
|
-
return utils.
|
|
1135
|
+
return utils.unmarshal_json_response(Any, http_res)
|
|
1253
1136
|
if utils.match_response(http_res, "422", "application/json"):
|
|
1254
|
-
response_data = utils.
|
|
1255
|
-
|
|
1137
|
+
response_data = utils.unmarshal_json_response(
|
|
1138
|
+
errors.HTTPValidationErrorData, http_res
|
|
1256
1139
|
)
|
|
1257
|
-
raise
|
|
1140
|
+
raise errors.HTTPValidationError(response_data, http_res)
|
|
1258
1141
|
if utils.match_response(http_res, "4XX", "*"):
|
|
1259
1142
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1260
|
-
raise
|
|
1261
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1262
|
-
)
|
|
1143
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1263
1144
|
if utils.match_response(http_res, "5XX", "*"):
|
|
1264
1145
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1265
|
-
raise
|
|
1266
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1267
|
-
)
|
|
1146
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1268
1147
|
|
|
1269
|
-
|
|
1270
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1271
|
-
raise models.APIError(
|
|
1272
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1273
|
-
http_res.status_code,
|
|
1274
|
-
http_res_text,
|
|
1275
|
-
http_res,
|
|
1276
|
-
)
|
|
1148
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
1277
1149
|
|
|
1278
1150
|
def users_delete_account(
|
|
1279
1151
|
self,
|
|
@@ -1342,26 +1214,15 @@ class Users(BaseSDK):
|
|
|
1342
1214
|
)
|
|
1343
1215
|
|
|
1344
1216
|
if utils.match_response(http_res, "200", "application/json"):
|
|
1345
|
-
return utils.
|
|
1217
|
+
return utils.unmarshal_json_response(Any, http_res)
|
|
1346
1218
|
if utils.match_response(http_res, "4XX", "*"):
|
|
1347
1219
|
http_res_text = utils.stream_to_text(http_res)
|
|
1348
|
-
raise
|
|
1349
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1350
|
-
)
|
|
1220
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1351
1221
|
if utils.match_response(http_res, "5XX", "*"):
|
|
1352
1222
|
http_res_text = utils.stream_to_text(http_res)
|
|
1353
|
-
raise
|
|
1354
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1355
|
-
)
|
|
1223
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1356
1224
|
|
|
1357
|
-
|
|
1358
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
1359
|
-
raise models.APIError(
|
|
1360
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1361
|
-
http_res.status_code,
|
|
1362
|
-
http_res_text,
|
|
1363
|
-
http_res,
|
|
1364
|
-
)
|
|
1225
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
1365
1226
|
|
|
1366
1227
|
async def users_delete_account_async(
|
|
1367
1228
|
self,
|
|
@@ -1430,23 +1291,12 @@ class Users(BaseSDK):
|
|
|
1430
1291
|
)
|
|
1431
1292
|
|
|
1432
1293
|
if utils.match_response(http_res, "200", "application/json"):
|
|
1433
|
-
return utils.
|
|
1294
|
+
return utils.unmarshal_json_response(Any, http_res)
|
|
1434
1295
|
if utils.match_response(http_res, "4XX", "*"):
|
|
1435
1296
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1436
|
-
raise
|
|
1437
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1438
|
-
)
|
|
1297
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1439
1298
|
if utils.match_response(http_res, "5XX", "*"):
|
|
1440
1299
|
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1441
|
-
raise
|
|
1442
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1443
|
-
)
|
|
1300
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1444
1301
|
|
|
1445
|
-
|
|
1446
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1447
|
-
raise models.APIError(
|
|
1448
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1449
|
-
http_res.status_code,
|
|
1450
|
-
http_res_text,
|
|
1451
|
-
http_res,
|
|
1452
|
-
)
|
|
1302
|
+
raise errors.APIError("Unexpected response received", http_res)
|
syllable_sdk/utils/__init__.py
CHANGED
|
@@ -29,6 +29,7 @@ if TYPE_CHECKING:
|
|
|
29
29
|
marshal_json,
|
|
30
30
|
unmarshal,
|
|
31
31
|
unmarshal_json,
|
|
32
|
+
unmarshal_json_response,
|
|
32
33
|
serialize_decimal,
|
|
33
34
|
serialize_float,
|
|
34
35
|
serialize_int,
|
|
@@ -98,6 +99,7 @@ __all__ = [
|
|
|
98
99
|
"template_url",
|
|
99
100
|
"unmarshal",
|
|
100
101
|
"unmarshal_json",
|
|
102
|
+
"unmarshal_json_response",
|
|
101
103
|
"validate_decimal",
|
|
102
104
|
"validate_const",
|
|
103
105
|
"validate_float",
|
|
@@ -152,6 +154,7 @@ _dynamic_imports: dict[str, str] = {
|
|
|
152
154
|
"template_url": ".url",
|
|
153
155
|
"unmarshal": ".serializers",
|
|
154
156
|
"unmarshal_json": ".serializers",
|
|
157
|
+
"unmarshal_json_response": ".serializers",
|
|
155
158
|
"validate_decimal": ".serializers",
|
|
156
159
|
"validate_const": ".serializers",
|
|
157
160
|
"validate_float": ".serializers",
|
|
@@ -4,7 +4,7 @@ from decimal import Decimal
|
|
|
4
4
|
import functools
|
|
5
5
|
import json
|
|
6
6
|
import typing
|
|
7
|
-
from typing import Any, Dict, List, Tuple, Union, get_args
|
|
7
|
+
from typing import Any, Dict, List, Optional, Tuple, Union, get_args
|
|
8
8
|
import typing_extensions
|
|
9
9
|
from typing_extensions import get_origin
|
|
10
10
|
|
|
@@ -13,6 +13,7 @@ from pydantic import ConfigDict, create_model
|
|
|
13
13
|
from pydantic_core import from_json
|
|
14
14
|
|
|
15
15
|
from ..types.basemodel import BaseModel, Nullable, OptionalNullable, Unset
|
|
16
|
+
from syllable_sdk import errors
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
def serialize_decimal(as_str: bool):
|
|
@@ -140,6 +141,22 @@ def unmarshal_json(raw, typ: Any) -> Any:
|
|
|
140
141
|
return unmarshal(from_json(raw), typ)
|
|
141
142
|
|
|
142
143
|
|
|
144
|
+
def unmarshal_json_response(
|
|
145
|
+
typ: Any, http_res: httpx.Response, body: Optional[str] = None
|
|
146
|
+
) -> Any:
|
|
147
|
+
if body is None:
|
|
148
|
+
body = http_res.text
|
|
149
|
+
try:
|
|
150
|
+
return unmarshal_json(body, typ)
|
|
151
|
+
except Exception as e:
|
|
152
|
+
raise errors.ResponseValidationError(
|
|
153
|
+
"Response validation failed",
|
|
154
|
+
http_res,
|
|
155
|
+
e,
|
|
156
|
+
body,
|
|
157
|
+
) from e
|
|
158
|
+
|
|
159
|
+
|
|
143
160
|
def unmarshal(val, typ: Any) -> Any:
|
|
144
161
|
unmarshaller = create_model(
|
|
145
162
|
"Unmarshaller",
|
|
@@ -192,7 +209,9 @@ def is_union(obj: object) -> bool:
|
|
|
192
209
|
"""
|
|
193
210
|
Returns True if the given object is a typing.Union or typing_extensions.Union.
|
|
194
211
|
"""
|
|
195
|
-
return any(
|
|
212
|
+
return any(
|
|
213
|
+
obj is typing_obj for typing_obj in _get_typing_objects_by_name_of("Union")
|
|
214
|
+
)
|
|
196
215
|
|
|
197
216
|
|
|
198
217
|
def stream_to_text(stream: httpx.Response) -> str:
|
|
@@ -245,4 +264,3 @@ def _get_typing_objects_by_name_of(name: str) -> Tuple[Any, ...]:
|
|
|
245
264
|
f"Neither typing nor typing_extensions has an object called {name!r}"
|
|
246
265
|
)
|
|
247
266
|
return result
|
|
248
|
-
|