sweatstack 0.19.2__py3-none-any.whl → 0.21.0__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.
- sweatstack/client.py +29 -8
- {sweatstack-0.19.2.dist-info → sweatstack-0.21.0.dist-info}/METADATA +1 -1
- {sweatstack-0.19.2.dist-info → sweatstack-0.21.0.dist-info}/RECORD +5 -5
- {sweatstack-0.19.2.dist-info → sweatstack-0.21.0.dist-info}/WHEEL +0 -0
- {sweatstack-0.19.2.dist-info → sweatstack-0.21.0.dist-info}/entry_points.txt +0 -0
sweatstack/client.py
CHANGED
|
@@ -24,7 +24,21 @@ from .schemas import (
|
|
|
24
24
|
from .utils import decode_jwt_body, make_dataframe_streamlit_compatible
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
AUTH_SUCCESSFUL_RESPONSE = "<!DOCTYPE html
|
|
27
|
+
AUTH_SUCCESSFUL_RESPONSE = """<!DOCTYPE html>
|
|
28
|
+
<html>
|
|
29
|
+
<head>
|
|
30
|
+
<style>
|
|
31
|
+
body { max-width: 600px; margin: 40px auto; text-align: center; }
|
|
32
|
+
h1 { color: #2C3E50; font-size: 24px; }
|
|
33
|
+
p { color: #34495E; font-size: 18px; }
|
|
34
|
+
</style>
|
|
35
|
+
</head>
|
|
36
|
+
<body>
|
|
37
|
+
<img src="https://sweatstack.no/images/sweat-stack-python-client.png" alt="SweatStack Logo" style="width: 200px; margin: 20px auto; display: block;">
|
|
38
|
+
<h1>Successfully authenticated with SweatStack!</h1>
|
|
39
|
+
<p>You have successfully authenticated using the SweatStack Python client library. You can now close this window and return to your Python environment.</p>
|
|
40
|
+
</body>
|
|
41
|
+
</html>"""
|
|
28
42
|
OAUTH2_CLIENT_ID = "5382f68b0d254378"
|
|
29
43
|
|
|
30
44
|
|
|
@@ -107,7 +121,14 @@ class OAuth2Mixin:
|
|
|
107
121
|
|
|
108
122
|
|
|
109
123
|
class DelegationMixin:
|
|
110
|
-
def
|
|
124
|
+
def _validate_user(self, user: str | UserSummary):
|
|
125
|
+
if isinstance(user, UserSummary):
|
|
126
|
+
return user.id
|
|
127
|
+
else:
|
|
128
|
+
return user
|
|
129
|
+
|
|
130
|
+
def _get_delegated_token(self, user: str | UserSummary):
|
|
131
|
+
user_id = self._validate_user(user)
|
|
111
132
|
with self._http_client() as client:
|
|
112
133
|
response = client.post(
|
|
113
134
|
"/api/v1/oauth/delegated-token",
|
|
@@ -117,8 +138,8 @@ class DelegationMixin:
|
|
|
117
138
|
|
|
118
139
|
return response.json()
|
|
119
140
|
|
|
120
|
-
def switch_user(self,
|
|
121
|
-
token_response = self._get_delegated_token(
|
|
141
|
+
def switch_user(self, user: str | UserSummary):
|
|
142
|
+
token_response = self._get_delegated_token(user)
|
|
122
143
|
self.api_key = token_response["access_token"]
|
|
123
144
|
self.refresh_token = token_response["refresh_token"]
|
|
124
145
|
|
|
@@ -135,8 +156,8 @@ class DelegationMixin:
|
|
|
135
156
|
self.api_key = token_response["access_token"]
|
|
136
157
|
self.refresh_token = token_response["refresh_token"]
|
|
137
158
|
|
|
138
|
-
def delegated_client(self,
|
|
139
|
-
token_response = self._get_delegated_token(
|
|
159
|
+
def delegated_client(self, user: str | UserSummary):
|
|
160
|
+
token_response = self._get_delegated_token(user)
|
|
140
161
|
return self.__class__(
|
|
141
162
|
api_key=token_response["access_token"],
|
|
142
163
|
refresh_token=token_response["refresh_token"],
|
|
@@ -604,7 +625,7 @@ class Client(OAuth2Mixin, DelegationMixin):
|
|
|
604
625
|
response.raise_for_status()
|
|
605
626
|
return response.json()
|
|
606
627
|
|
|
607
|
-
def
|
|
628
|
+
def get_users(self) -> list[UserSummary]:
|
|
608
629
|
with self._http_client() as client:
|
|
609
630
|
response = client.get(
|
|
610
631
|
url="/api/v1/users/",
|
|
@@ -651,7 +672,7 @@ _generate_singleton_methods(
|
|
|
651
672
|
[
|
|
652
673
|
"login",
|
|
653
674
|
|
|
654
|
-
"
|
|
675
|
+
"get_users",
|
|
655
676
|
|
|
656
677
|
"get_activities",
|
|
657
678
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
sweatstack/__init__.py,sha256=tiVfgKlswRPaDMEy0gA7u8rveqEYZTA_kyB9lJ3J6Sc,21
|
|
2
2
|
sweatstack/cli.py,sha256=N1NWOgEZR2yaJvIXxo9qvp_jFlypZYb0nujpbVNYQ6A,720
|
|
3
|
-
sweatstack/client.py,sha256=
|
|
3
|
+
sweatstack/client.py,sha256=NOLQpOBsSPmYjtZ4GgutMKTcu5efYeD_WVNHThmecIs,22918
|
|
4
4
|
sweatstack/constants.py,sha256=fGO6ksOv5HeISv9lHRoYm4besW1GTveXS8YD3K0ljg0,41
|
|
5
5
|
sweatstack/ipython_init.py,sha256=zBGUlMFkdpLvsNpOpwrNaKRUpUZhzaICvH8ODJgMPcI,229
|
|
6
6
|
sweatstack/jupyterlab_oauth2_startup.py,sha256=eZ6xi0Sa4hO4vUanimq0SqjduHtiywCURSDNWk_I-7s,1200
|
|
@@ -11,7 +11,7 @@ sweatstack/streamlit.py,sha256=F5oQdWkcJ76Um5fRqFT5QrjpEz8v3OaiH9kMQOYktgo,4466
|
|
|
11
11
|
sweatstack/sweatshell.py,sha256=MYLNcWbOdceqKJ3S0Pe8dwHXEeYsGJNjQoYUXpMTftA,333
|
|
12
12
|
sweatstack/utils.py,sha256=HtR1NNCKus59vfgfaCSFS-tHA11mtdcuUx5lS6ZX58g,1773
|
|
13
13
|
sweatstack/Sweat Stack examples/Getting started.ipynb,sha256=k2hiSffWecoQ0VxjdpDcgFzBXDQiYEebhnAYlu8cgX8,6335204
|
|
14
|
-
sweatstack-0.
|
|
15
|
-
sweatstack-0.
|
|
16
|
-
sweatstack-0.
|
|
17
|
-
sweatstack-0.
|
|
14
|
+
sweatstack-0.21.0.dist-info/METADATA,sha256=aisPV_mLRm4mvM0TMo4Jv5jxixydBIQH5ijxNBh1ZZg,2962
|
|
15
|
+
sweatstack-0.21.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
16
|
+
sweatstack-0.21.0.dist-info/entry_points.txt,sha256=kCzOUQI3dqbTpEYqtgYDeiKFaqaA7BMlV6D24BMzCFU,208
|
|
17
|
+
sweatstack-0.21.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|