sweatstack 0.19.1__py3-none-any.whl → 0.20.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 CHANGED
@@ -107,7 +107,14 @@ class OAuth2Mixin:
107
107
 
108
108
 
109
109
  class DelegationMixin:
110
- def _get_delegated_token(self, user_id: str):
110
+ def _validate_user(self, user: str | UserSummary):
111
+ if isinstance(user, UserSummary):
112
+ return user.id
113
+ else:
114
+ return user
115
+
116
+ def _get_delegated_token(self, user: str | UserSummary):
117
+ user_id = self._validate_user(user)
111
118
  with self._http_client() as client:
112
119
  response = client.post(
113
120
  "/api/v1/oauth/delegated-token",
@@ -117,8 +124,8 @@ class DelegationMixin:
117
124
 
118
125
  return response.json()
119
126
 
120
- def switch_user(self, user_id: str):
121
- token_response = self._get_delegated_token(user_id)
127
+ def switch_user(self, user: str | UserSummary):
128
+ token_response = self._get_delegated_token(user)
122
129
  self.api_key = token_response["access_token"]
123
130
  self.refresh_token = token_response["refresh_token"]
124
131
 
@@ -135,8 +142,8 @@ class DelegationMixin:
135
142
  self.api_key = token_response["access_token"]
136
143
  self.refresh_token = token_response["refresh_token"]
137
144
 
138
- def delegated_client(self, user_id: str):
139
- token_response = self._get_delegated_token(user_id)
145
+ def delegated_client(self, user: str | UserSummary):
146
+ token_response = self._get_delegated_token(user)
140
147
  return self.__class__(
141
148
  api_key=token_response["access_token"],
142
149
  refresh_token=token_response["refresh_token"],
@@ -154,7 +161,7 @@ class DelegationMixin:
154
161
  )
155
162
 
156
163
 
157
- class Client(OAuth2Mixin, DelegationMixin, JupyterInteractivityMixin):
164
+ class Client(OAuth2Mixin, DelegationMixin):
158
165
  def __init__(
159
166
  self,
160
167
  api_key: str | None = None,
@@ -604,7 +611,7 @@ class Client(OAuth2Mixin, DelegationMixin, JupyterInteractivityMixin):
604
611
  response.raise_for_status()
605
612
  return response.json()
606
613
 
607
- def list_users(self) -> list[UserSummary]:
614
+ def get_users(self) -> list[UserSummary]:
608
615
  with self._http_client() as client:
609
616
  response = client.get(
610
617
  url="/api/v1/users/",
@@ -651,7 +658,7 @@ _generate_singleton_methods(
651
658
  [
652
659
  "login",
653
660
 
654
- "list_users",
661
+ "get_users",
655
662
 
656
663
  "get_activities",
657
664
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sweatstack
3
- Version: 0.19.1
3
+ Version: 0.20.0
4
4
  Summary: The official Python client for SweatStack
5
5
  Author-email: Aart Goossens <aart@gssns.io>
6
6
  Requires-Python: >=3.12
@@ -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=iPSuaRZRQIJUygywZL2PWkCMIeDm6ErSdSDwCPM_PtQ,22191
3
+ sweatstack/client.py,sha256=8oYnYisQHRJWdEUO_SqIf0xU48PvkInUO90LYwr98Qo,22396
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.19.1.dist-info/METADATA,sha256=zj_LBkQjFACMDH_c7lWV7rPttI_lG9muNqzY45QgXFA,2962
15
- sweatstack-0.19.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- sweatstack-0.19.1.dist-info/entry_points.txt,sha256=kCzOUQI3dqbTpEYqtgYDeiKFaqaA7BMlV6D24BMzCFU,208
17
- sweatstack-0.19.1.dist-info/RECORD,,
14
+ sweatstack-0.20.0.dist-info/METADATA,sha256=DbpDHyf-ffe-w3whUXOdksfENiOR1ikQyfnvzVcPMYM,2962
15
+ sweatstack-0.20.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ sweatstack-0.20.0.dist-info/entry_points.txt,sha256=kCzOUQI3dqbTpEYqtgYDeiKFaqaA7BMlV6D24BMzCFU,208
17
+ sweatstack-0.20.0.dist-info/RECORD,,