volcano-sdk-python 0.7.2__py3-none-any.whl → 0.7.3__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.
- volcano_sdk/_transport.py +54 -12
- volcano_sdk/auth.py +49 -29
- {volcano_sdk_python-0.7.2.dist-info → volcano_sdk_python-0.7.3.dist-info}/METADATA +3 -1
- {volcano_sdk_python-0.7.2.dist-info → volcano_sdk_python-0.7.3.dist-info}/RECORD +6 -6
- {volcano_sdk_python-0.7.2.dist-info → volcano_sdk_python-0.7.3.dist-info}/WHEEL +1 -1
- {volcano_sdk_python-0.7.2.dist-info → volcano_sdk_python-0.7.3.dist-info}/licenses/LICENSE +0 -0
volcano_sdk/_transport.py
CHANGED
|
@@ -13,14 +13,10 @@ from uuid import UUID, uuid4
|
|
|
13
13
|
import httpx
|
|
14
14
|
|
|
15
15
|
from ._generated.api.authentication import (
|
|
16
|
-
auth_confirm_email_change,
|
|
17
|
-
auth_convert_anonymous,
|
|
18
|
-
auth_get_user,
|
|
19
16
|
auth_logout,
|
|
20
17
|
auth_refresh,
|
|
21
18
|
auth_signin,
|
|
22
19
|
auth_signup,
|
|
23
|
-
auth_update_user,
|
|
24
20
|
)
|
|
25
21
|
from ._generated.api.authentication.auth_cancel_email_change import (
|
|
26
22
|
_get_kwargs as cancel_email_change_kwargs,
|
|
@@ -28,6 +24,18 @@ from ._generated.api.authentication.auth_cancel_email_change import (
|
|
|
28
24
|
from ._generated.api.authentication.auth_confirm_email import (
|
|
29
25
|
_get_kwargs as confirm_email_kwargs,
|
|
30
26
|
)
|
|
27
|
+
from ._generated.api.authentication.auth_confirm_email_change import (
|
|
28
|
+
_build_response as build_auth_confirm_email_change_response,
|
|
29
|
+
)
|
|
30
|
+
from ._generated.api.authentication.auth_confirm_email_change import (
|
|
31
|
+
_get_kwargs as auth_confirm_email_change_kwargs,
|
|
32
|
+
)
|
|
33
|
+
from ._generated.api.authentication.auth_convert_anonymous import (
|
|
34
|
+
_build_response as build_auth_convert_anonymous_response,
|
|
35
|
+
)
|
|
36
|
+
from ._generated.api.authentication.auth_convert_anonymous import (
|
|
37
|
+
_get_kwargs as auth_convert_anonymous_kwargs,
|
|
38
|
+
)
|
|
31
39
|
from ._generated.api.authentication.auth_delete_all_my_sessions import (
|
|
32
40
|
_get_kwargs as delete_all_my_sessions_kwargs,
|
|
33
41
|
)
|
|
@@ -40,6 +48,12 @@ from ._generated.api.authentication.auth_forgot_password import (
|
|
|
40
48
|
from ._generated.api.authentication.auth_get_my_sessions import (
|
|
41
49
|
_get_kwargs as get_my_sessions_kwargs,
|
|
42
50
|
)
|
|
51
|
+
from ._generated.api.authentication.auth_get_user import (
|
|
52
|
+
_build_response as build_auth_get_user_response,
|
|
53
|
+
)
|
|
54
|
+
from ._generated.api.authentication.auth_get_user import (
|
|
55
|
+
_get_kwargs as auth_get_user_kwargs,
|
|
56
|
+
)
|
|
43
57
|
from ._generated.api.authentication.auth_request_email_change import (
|
|
44
58
|
_get_kwargs as request_email_change_kwargs,
|
|
45
59
|
)
|
|
@@ -52,6 +66,12 @@ from ._generated.api.authentication.auth_reset_password import (
|
|
|
52
66
|
from ._generated.api.authentication.auth_signup_anonymous import (
|
|
53
67
|
_get_kwargs as signup_anonymous_kwargs,
|
|
54
68
|
)
|
|
69
|
+
from ._generated.api.authentication.auth_update_user import (
|
|
70
|
+
_build_response as build_auth_update_user_response,
|
|
71
|
+
)
|
|
72
|
+
from ._generated.api.authentication.auth_update_user import (
|
|
73
|
+
_get_kwargs as auth_update_user_kwargs,
|
|
74
|
+
)
|
|
55
75
|
from ._generated.api.database_queries import (
|
|
56
76
|
query_database_select,
|
|
57
77
|
)
|
|
@@ -829,9 +849,13 @@ class GeneratedTransport:
|
|
|
829
849
|
)
|
|
830
850
|
try:
|
|
831
851
|
with self._client(authorization) as client:
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
852
|
+
raw_response = client.get_httpx_client().request(
|
|
853
|
+
**auth_convert_anonymous_kwargs(body=body)
|
|
854
|
+
)
|
|
855
|
+
if raw_response.status_code == HTTP_UNAUTHORIZED:
|
|
856
|
+
return self._raw_response(raw_response)
|
|
857
|
+
response = build_auth_convert_anonymous_response(
|
|
858
|
+
client=client, response=raw_response
|
|
835
859
|
)
|
|
836
860
|
except (
|
|
837
861
|
AttributeError,
|
|
@@ -928,9 +952,13 @@ class GeneratedTransport:
|
|
|
928
952
|
body = AuthConfirmEmailChangeBody(email_change_token=token)
|
|
929
953
|
try:
|
|
930
954
|
with self._client(authorization) as client:
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
955
|
+
raw_response = client.get_httpx_client().request(
|
|
956
|
+
**auth_confirm_email_change_kwargs(body=body)
|
|
957
|
+
)
|
|
958
|
+
if raw_response.status_code == HTTP_UNAUTHORIZED:
|
|
959
|
+
return self._raw_response(raw_response)
|
|
960
|
+
response = build_auth_confirm_email_change_response(
|
|
961
|
+
client=client, response=raw_response
|
|
934
962
|
)
|
|
935
963
|
except (
|
|
936
964
|
AttributeError,
|
|
@@ -1204,7 +1232,14 @@ class GeneratedTransport:
|
|
|
1204
1232
|
def auth_get_user(self, *, authorization: str) -> TransportResponse:
|
|
1205
1233
|
try:
|
|
1206
1234
|
with self._client(authorization) as client:
|
|
1207
|
-
|
|
1235
|
+
raw_response = client.get_httpx_client().request(
|
|
1236
|
+
**auth_get_user_kwargs()
|
|
1237
|
+
)
|
|
1238
|
+
if raw_response.status_code == HTTP_UNAUTHORIZED:
|
|
1239
|
+
return self._raw_response(raw_response)
|
|
1240
|
+
response = build_auth_get_user_response(
|
|
1241
|
+
client=client, response=raw_response
|
|
1242
|
+
)
|
|
1208
1243
|
except (
|
|
1209
1244
|
AttributeError,
|
|
1210
1245
|
KeyError,
|
|
@@ -1239,7 +1274,14 @@ class GeneratedTransport:
|
|
|
1239
1274
|
)
|
|
1240
1275
|
try:
|
|
1241
1276
|
with self._client(authorization) as client:
|
|
1242
|
-
|
|
1277
|
+
raw_response = client.get_httpx_client().request(
|
|
1278
|
+
**auth_update_user_kwargs(body=body)
|
|
1279
|
+
)
|
|
1280
|
+
if raw_response.status_code == HTTP_UNAUTHORIZED:
|
|
1281
|
+
return self._raw_response(raw_response)
|
|
1282
|
+
response = build_auth_update_user_response(
|
|
1283
|
+
client=client, response=raw_response
|
|
1284
|
+
)
|
|
1243
1285
|
except (
|
|
1244
1286
|
AttributeError,
|
|
1245
1287
|
KeyError,
|
volcano_sdk/auth.py
CHANGED
|
@@ -9,6 +9,7 @@ import secrets
|
|
|
9
9
|
import threading
|
|
10
10
|
from collections.abc import Mapping
|
|
11
11
|
from contextlib import suppress
|
|
12
|
+
from copy import deepcopy
|
|
12
13
|
from dataclasses import replace
|
|
13
14
|
from datetime import datetime
|
|
14
15
|
from http import HTTPStatus
|
|
@@ -574,18 +575,22 @@ class Auth:
|
|
|
574
575
|
metadata: Mapping[str, object] | None = None,
|
|
575
576
|
) -> User:
|
|
576
577
|
"""Attach email credentials to the current anonymous account."""
|
|
577
|
-
|
|
578
|
-
if
|
|
578
|
+
binding = self._client._capture_session_binding()
|
|
579
|
+
if binding[2] is None:
|
|
579
580
|
raise AuthenticationError(_NO_ACTIVE_SESSION)
|
|
580
581
|
transport = cast("AuthConvertAnonymousTransport", self._client._transport)
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
582
|
+
request_metadata = deepcopy(dict(metadata or {}))
|
|
583
|
+
response = self._session_request(
|
|
584
|
+
lambda access_token: invoke(
|
|
585
|
+
transport.auth_convert_anonymous,
|
|
586
|
+
authorization=access_token,
|
|
587
|
+
email=email,
|
|
588
|
+
password=password,
|
|
589
|
+
metadata=request_metadata,
|
|
590
|
+
),
|
|
591
|
+
binding=binding,
|
|
587
592
|
)
|
|
588
|
-
return self._update_current_user(response_payload(response, 200),
|
|
593
|
+
return self._update_current_user(response_payload(response, 200), binding)
|
|
589
594
|
|
|
590
595
|
def reset_password_for_email(self, *, email: str) -> None:
|
|
591
596
|
"""Request a reset email without revealing whether the account exists."""
|
|
@@ -629,16 +634,19 @@ class Auth:
|
|
|
629
634
|
|
|
630
635
|
def confirm_email_change(self, *, token: str) -> User:
|
|
631
636
|
"""Confirm a pending email change and return the updated user."""
|
|
632
|
-
|
|
633
|
-
if
|
|
637
|
+
binding = self._client._capture_session_binding()
|
|
638
|
+
if binding[2] is None:
|
|
634
639
|
raise AuthenticationError(_NO_ACTIVE_SESSION)
|
|
635
640
|
transport = cast("AuthConfirmEmailChangeTransport", self._client._transport)
|
|
636
|
-
response =
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
641
|
+
response = self._session_request(
|
|
642
|
+
lambda access_token: invoke(
|
|
643
|
+
transport.auth_confirm_email_change,
|
|
644
|
+
authorization=access_token,
|
|
645
|
+
token=token,
|
|
646
|
+
),
|
|
647
|
+
binding=binding,
|
|
640
648
|
)
|
|
641
|
-
return self._update_current_user(response_payload(response, 200),
|
|
649
|
+
return self._update_current_user(response_payload(response, 200), binding)
|
|
642
650
|
|
|
643
651
|
def delete_all_other_sessions(self) -> None:
|
|
644
652
|
"""Delete every other session while preserving the current session."""
|
|
@@ -944,7 +952,10 @@ class Auth:
|
|
|
944
952
|
)
|
|
945
953
|
response_payload(response, 200)
|
|
946
954
|
|
|
947
|
-
def _update_current_user(
|
|
955
|
+
def _update_current_user(
|
|
956
|
+
self, payload: object, binding: tuple[int, int, Session | None]
|
|
957
|
+
) -> User:
|
|
958
|
+
generation = self._owned_refresh_session(binding)[0]
|
|
948
959
|
user, snapshot = _user_from_payload(payload)
|
|
949
960
|
if not self._client._update_session_user_if_current(snapshot, generation):
|
|
950
961
|
raise SessionChangedError
|
|
@@ -952,12 +963,17 @@ class Auth:
|
|
|
952
963
|
|
|
953
964
|
def get_user(self) -> User:
|
|
954
965
|
"""Load a server-validated profile for the current session."""
|
|
955
|
-
|
|
956
|
-
if
|
|
966
|
+
binding = self._client._capture_session_binding()
|
|
967
|
+
if binding[2] is None:
|
|
957
968
|
raise AuthenticationError(_NO_ACTIVE_SESSION)
|
|
958
969
|
transport = cast("AuthGetUserTransport", self._client._transport)
|
|
959
|
-
response =
|
|
960
|
-
|
|
970
|
+
response = self._session_request(
|
|
971
|
+
lambda access_token: invoke(
|
|
972
|
+
transport.auth_get_user, authorization=access_token
|
|
973
|
+
),
|
|
974
|
+
binding=binding,
|
|
975
|
+
)
|
|
976
|
+
return self._update_current_user(response_payload(response, 200), binding)
|
|
961
977
|
|
|
962
978
|
def update_user(
|
|
963
979
|
self,
|
|
@@ -966,17 +982,21 @@ class Auth:
|
|
|
966
982
|
metadata: Mapping[str, object] | None = None,
|
|
967
983
|
) -> User:
|
|
968
984
|
"""Update and return the current user's server-validated profile."""
|
|
969
|
-
|
|
970
|
-
if
|
|
985
|
+
binding = self._client._capture_session_binding()
|
|
986
|
+
if binding[2] is None:
|
|
971
987
|
raise AuthenticationError(_NO_ACTIVE_SESSION)
|
|
972
988
|
transport = cast("AuthUpdateUserTransport", self._client._transport)
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
989
|
+
request_metadata = None if metadata is None else deepcopy(dict(metadata))
|
|
990
|
+
response = self._session_request(
|
|
991
|
+
lambda access_token: invoke(
|
|
992
|
+
transport.auth_update_user,
|
|
993
|
+
authorization=access_token,
|
|
994
|
+
password=password,
|
|
995
|
+
metadata=request_metadata,
|
|
996
|
+
),
|
|
997
|
+
binding=binding,
|
|
978
998
|
)
|
|
979
|
-
return self._update_current_user(response_payload(response, 200),
|
|
999
|
+
return self._update_current_user(response_payload(response, 200), binding)
|
|
980
1000
|
|
|
981
1001
|
def sign_in(self, *, email: str, password: str) -> Session:
|
|
982
1002
|
"""Sign in a user and store the returned session."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: volcano-sdk-python
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.3
|
|
4
4
|
Summary: Official Python SDK for Volcano
|
|
5
5
|
Project-URL: Homepage, https://volcano.dev
|
|
6
6
|
Project-URL: Repository, https://github.com/Kong/volcano-sdk-python
|
|
@@ -25,6 +25,8 @@ Description-Content-Type: text/markdown
|
|
|
25
25
|
Use the Volcano Python SDK to access authentication, databases, storage,
|
|
26
26
|
functions, locks, logs, and realtime events. Requires Python 3.11 or later.
|
|
27
27
|
|
|
28
|
+
Start with the [Python quickstart](https://github.com/Kong/volcano-sdk-python/blob/main/docs/README.md).
|
|
29
|
+
|
|
28
30
|
## Install
|
|
29
31
|
|
|
30
32
|
```shell
|
|
@@ -4,8 +4,8 @@ volcano_sdk/_lock_guard.py,sha256=EZzcwOPTFTCNUrIWIQ0-nMg9tm_nPkaYkcocgeLbu94,55
|
|
|
4
4
|
volcano_sdk/_lock_renewer.py,sha256=tFo1ZeRiPKB5VSbW61uoMpNR67ZDYyMEe-dCjpAM3As,841
|
|
5
5
|
volcano_sdk/_lock_worker.py,sha256=QhSmwR0WcwgT-7ueJMlbCogLqOakQ5eRAtyWV74fgV0,3057
|
|
6
6
|
volcano_sdk/_realtime_fetch_worker.py,sha256=zQTgFF4cIUBeAL4J2OpWAlz_sIynv2BLfu588EogAdo,9269
|
|
7
|
-
volcano_sdk/_transport.py,sha256=
|
|
8
|
-
volcano_sdk/auth.py,sha256=
|
|
7
|
+
volcano_sdk/_transport.py,sha256=PzdO7uhqvgI2L-Ff0rwZCWeF7yuH_Ty-OvZx0F7dMpo,57509
|
|
8
|
+
volcano_sdk/auth.py,sha256=Z5UCrqdvmHBS6n6ZleXya04hYV94rH4SRV1GW2yimXo,43185
|
|
9
9
|
volcano_sdk/client.py,sha256=KutjBUOEJyK73OibKilrcWazpWeXKEZYUehSAH8qxUE,10366
|
|
10
10
|
volcano_sdk/connection_string.py,sha256=LlTZigsrCF4IfAqQ8SDTWJv35hnnzNu1MfeVv5JW-Kk,2331
|
|
11
11
|
volcano_sdk/database.py,sha256=p_5OaqlBjKAtIUfKQCflXM_CGqokrVmpOMsp6KHiJ8A,9493
|
|
@@ -773,7 +773,7 @@ volcano_sdk/_generated/models/usage_data_point.py,sha256=d4U08JbVTiIMM_l2BmRILL1
|
|
|
773
773
|
volcano_sdk/_generated/models/variable.py,sha256=tvGDOMv77gW6j5skufnfrlNAhzCzA1F7nuPCQWx79yY,5926
|
|
774
774
|
volcano_sdk/_generated/models/variable_deploy_source.py,sha256=G_aCiFHzQx8WhJFs0GvYZEFclfTrfkDvd3kT1e3vty8,463
|
|
775
775
|
volcano_sdk/_generated/models/variable_status.py,sha256=THSsKBSiAYG4kAtBzGA4TZqxjgx8hdL0Q4qCdZfOj00,391
|
|
776
|
-
volcano_sdk_python-0.7.
|
|
777
|
-
volcano_sdk_python-0.7.
|
|
778
|
-
volcano_sdk_python-0.7.
|
|
779
|
-
volcano_sdk_python-0.7.
|
|
776
|
+
volcano_sdk_python-0.7.3.dist-info/METADATA,sha256=0lDdNzghgpaKsYFFqMZZrWCn0rUt9nqdaGWSg0FhU_U,33557
|
|
777
|
+
volcano_sdk_python-0.7.3.dist-info/WHEEL,sha256=THafob7ofN-NsuMN7Mg4qZyHaQI7KkD-QlcQatYhXPo,87
|
|
778
|
+
volcano_sdk_python-0.7.3.dist-info/licenses/LICENSE,sha256=AIHJy-5MFqM8fHfuGFTTb9a8rvJGypcVgN4aZ-7XTWw,11387
|
|
779
|
+
volcano_sdk_python-0.7.3.dist-info/RECORD,,
|
|
File without changes
|