terrakio-core 0.2.1__py3-none-any.whl → 0.2.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.
Potentially problematic release.
This version of terrakio-core might be problematic. Click here for more details.
- {terrakio_core-0.2.1.dist-info → terrakio_core-0.2.3.dist-info}/METADATA +3 -7
- terrakio_core-0.2.3.dist-info/RECORD +4 -0
- {terrakio_core-0.2.1.dist-info → terrakio_core-0.2.3.dist-info}/WHEEL +1 -1
- terrakio_core-0.2.3.dist-info/top_level.txt +1 -0
- terrakio_core/__init__.py +0 -0
- terrakio_core/auth.py +0 -237
- terrakio_core/client.py +0 -829
- terrakio_core/config.py +0 -81
- terrakio_core/dataset_management.py +0 -235
- terrakio_core/exceptions.py +0 -18
- terrakio_core/mass_stats.py +0 -262
- terrakio_core/user_management.py +0 -227
- terrakio_core-0.2.1.dist-info/RECORD +0 -12
- terrakio_core-0.2.1.dist-info/top_level.txt +0 -1
terrakio_core/user_management.py
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
from typing import Dict, Any, List, Optional
|
|
3
|
-
from .exceptions import APIError, ConfigurationError
|
|
4
|
-
|
|
5
|
-
class UserManagement:
|
|
6
|
-
def __init__(self, api_url: str, api_key: str, verify: bool = True, timeout: int = 60):
|
|
7
|
-
"""
|
|
8
|
-
Initialize the User Management client.
|
|
9
|
-
|
|
10
|
-
Args:
|
|
11
|
-
api_url: API base URL
|
|
12
|
-
api_key: API key for authentication
|
|
13
|
-
verify: Verify SSL certificates
|
|
14
|
-
timeout: Request timeout in seconds
|
|
15
|
-
"""
|
|
16
|
-
self.api_url = api_url.rstrip('/')
|
|
17
|
-
self.api_key = api_key
|
|
18
|
-
self.verify = verify
|
|
19
|
-
self.timeout = timeout
|
|
20
|
-
self.session = requests.Session()
|
|
21
|
-
self.session.headers.update({
|
|
22
|
-
'x-api-key': self.api_key,
|
|
23
|
-
'Content-Type': 'application/json'
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
def get_user_by_id(self, user_id: str) -> Dict[str, Any]:
|
|
27
|
-
"""
|
|
28
|
-
Retrieve user info by user ID.
|
|
29
|
-
|
|
30
|
-
Args:
|
|
31
|
-
user_id: User ID to retrieve
|
|
32
|
-
|
|
33
|
-
Returns:
|
|
34
|
-
User information as a dictionary
|
|
35
|
-
|
|
36
|
-
Raises:
|
|
37
|
-
APIError: If the API request fails
|
|
38
|
-
"""
|
|
39
|
-
endpoint = f"{self.api_url}/admin/users/{user_id}"
|
|
40
|
-
try:
|
|
41
|
-
response = self.session.get(
|
|
42
|
-
endpoint,
|
|
43
|
-
timeout=self.timeout,
|
|
44
|
-
verify=self.verify
|
|
45
|
-
)
|
|
46
|
-
if not response.ok:
|
|
47
|
-
raise APIError(f"API request failed: {response.status_code} {response.reason}")
|
|
48
|
-
return response.json()
|
|
49
|
-
except requests.RequestException as e:
|
|
50
|
-
raise APIError(f"Request failed: {str(e)}")
|
|
51
|
-
|
|
52
|
-
def get_user_by_email(self, email: str) -> Dict[str, Any]:
|
|
53
|
-
"""
|
|
54
|
-
Retrieve user info by email.
|
|
55
|
-
|
|
56
|
-
Args:
|
|
57
|
-
email: User email to retrieve
|
|
58
|
-
|
|
59
|
-
Returns:
|
|
60
|
-
User information as a dictionary
|
|
61
|
-
|
|
62
|
-
Raises:
|
|
63
|
-
APIError: If the API request fails
|
|
64
|
-
"""
|
|
65
|
-
|
|
66
|
-
endpoint = f"{self.api_url}/admin/users/email/{email}"
|
|
67
|
-
try:
|
|
68
|
-
response = self.session.get(
|
|
69
|
-
endpoint,
|
|
70
|
-
timeout=self.timeout,
|
|
71
|
-
verify=self.verify
|
|
72
|
-
)
|
|
73
|
-
if not response.ok:
|
|
74
|
-
raise APIError(f"API request failed: {response.status_code} {response.reason}")
|
|
75
|
-
return response.json()
|
|
76
|
-
except requests.RequestException as e:
|
|
77
|
-
raise APIError(f"Request failed: {str(e)}")
|
|
78
|
-
|
|
79
|
-
def edit_user(
|
|
80
|
-
self,
|
|
81
|
-
user_id: str,
|
|
82
|
-
uid: Optional[str] = None,
|
|
83
|
-
email: Optional[str] = None,
|
|
84
|
-
role: Optional[str] = None,
|
|
85
|
-
apiKey: Optional[str] = None,
|
|
86
|
-
groups: Optional[List[str]] = None,
|
|
87
|
-
quota: Optional[int] = None
|
|
88
|
-
) -> Dict[str, Any]:
|
|
89
|
-
"""
|
|
90
|
-
Edit user info. Only provided fields will be updated.
|
|
91
|
-
|
|
92
|
-
Args:
|
|
93
|
-
user_id: User ID (required)
|
|
94
|
-
uid: New user ID (optional)
|
|
95
|
-
email: New user email (optional)
|
|
96
|
-
role: New user role (optional)
|
|
97
|
-
apiKey: New API key (optional)
|
|
98
|
-
groups: New list of groups (optional)
|
|
99
|
-
quota: New quota value (optional)
|
|
100
|
-
|
|
101
|
-
Returns:
|
|
102
|
-
Updated user information
|
|
103
|
-
|
|
104
|
-
Raises:
|
|
105
|
-
APIError: If the API request fails
|
|
106
|
-
"""
|
|
107
|
-
endpoint = f"{self.api_url}/admin/users"
|
|
108
|
-
payload = {"uid": user_id}
|
|
109
|
-
|
|
110
|
-
if uid is not None:
|
|
111
|
-
payload["uid"] = uid
|
|
112
|
-
if email is not None:
|
|
113
|
-
payload["email"] = email
|
|
114
|
-
if role is not None:
|
|
115
|
-
payload["role"] = role
|
|
116
|
-
if apiKey is not None:
|
|
117
|
-
payload["apiKey"] = apiKey
|
|
118
|
-
if groups is not None:
|
|
119
|
-
payload["groups"] = groups
|
|
120
|
-
if quota is not None:
|
|
121
|
-
payload["quota"] = quota
|
|
122
|
-
|
|
123
|
-
try:
|
|
124
|
-
response = self.session.patch(
|
|
125
|
-
endpoint,
|
|
126
|
-
json=payload,
|
|
127
|
-
timeout=self.timeout,
|
|
128
|
-
verify=self.verify
|
|
129
|
-
)
|
|
130
|
-
if not response.ok:
|
|
131
|
-
raise APIError(f"API request failed: {response.status_code} {response.reason}")
|
|
132
|
-
return response.json()
|
|
133
|
-
except requests.RequestException as e:
|
|
134
|
-
raise APIError(f"Request failed: {str(e)}")
|
|
135
|
-
|
|
136
|
-
def list_users(self, substring: Optional[str] = None, uid: bool = False) -> List[Dict[str, Any]]:
|
|
137
|
-
"""
|
|
138
|
-
List users, optionally filtering by a substring.
|
|
139
|
-
|
|
140
|
-
Args:
|
|
141
|
-
substring: Optional substring to filter users
|
|
142
|
-
uid: If True, includes the user ID in the response (default: False)
|
|
143
|
-
|
|
144
|
-
Returns:
|
|
145
|
-
List of users
|
|
146
|
-
|
|
147
|
-
Raises:
|
|
148
|
-
APIError: If the API request fails
|
|
149
|
-
"""
|
|
150
|
-
# Use the base API URL instead of hardcoding
|
|
151
|
-
endpoint = "https://terrakio-server-lark-573248941006.australia-southeast1.run.app/admin/users"
|
|
152
|
-
|
|
153
|
-
params = {}
|
|
154
|
-
if substring:
|
|
155
|
-
params["substring"] = substring
|
|
156
|
-
if uid:
|
|
157
|
-
params["uid"] = "true"
|
|
158
|
-
|
|
159
|
-
try:
|
|
160
|
-
response = self.session.get(
|
|
161
|
-
endpoint,
|
|
162
|
-
params=params,
|
|
163
|
-
timeout=self.timeout,
|
|
164
|
-
verify=self.verify
|
|
165
|
-
)
|
|
166
|
-
if not response.ok:
|
|
167
|
-
raise APIError(f"API request failed: {response.status_code} {response.reason}")
|
|
168
|
-
return response.json()
|
|
169
|
-
except requests.RequestException as e:
|
|
170
|
-
raise APIError(f"Request failed: {str(e)}")
|
|
171
|
-
|
|
172
|
-
def reset_quota(self, email: str, quota: Optional[int] = None) -> Dict[str, Any]:
|
|
173
|
-
"""
|
|
174
|
-
Reset the quota for a user by email.
|
|
175
|
-
|
|
176
|
-
Args:
|
|
177
|
-
email: The user's email (required)
|
|
178
|
-
quota: The new quota value (optional)
|
|
179
|
-
|
|
180
|
-
Returns:
|
|
181
|
-
API response as a dictionary
|
|
182
|
-
|
|
183
|
-
Raises:
|
|
184
|
-
APIError: If the API request fails
|
|
185
|
-
"""
|
|
186
|
-
endpoint = f"{self.api_url}/admin/users/reset_quota/{email}"
|
|
187
|
-
payload = {"email": email}
|
|
188
|
-
if quota is not None:
|
|
189
|
-
payload["quota"] = quota
|
|
190
|
-
try:
|
|
191
|
-
response = self.session.patch(
|
|
192
|
-
endpoint,
|
|
193
|
-
json=payload,
|
|
194
|
-
timeout=self.timeout,
|
|
195
|
-
verify=self.verify
|
|
196
|
-
)
|
|
197
|
-
if not response.ok:
|
|
198
|
-
raise APIError(f"API request failed: {response.status_code} {response.reason}")
|
|
199
|
-
return response.json()
|
|
200
|
-
except requests.RequestException as e:
|
|
201
|
-
raise APIError(f"Request failed: {str(e)}")
|
|
202
|
-
|
|
203
|
-
def delete_user(self, uid: str) -> Dict[str, Any]:
|
|
204
|
-
"""
|
|
205
|
-
Delete a user by UID.
|
|
206
|
-
|
|
207
|
-
Args:
|
|
208
|
-
uid: The user's UID (required)
|
|
209
|
-
|
|
210
|
-
Returns:
|
|
211
|
-
API response as a dictionary
|
|
212
|
-
|
|
213
|
-
Raises:
|
|
214
|
-
APIError: If the API request fails
|
|
215
|
-
"""
|
|
216
|
-
endpoint = f"{self.api_url}/admin/users/{uid}"
|
|
217
|
-
try:
|
|
218
|
-
response = self.session.delete(
|
|
219
|
-
endpoint,
|
|
220
|
-
timeout=self.timeout,
|
|
221
|
-
verify=self.verify
|
|
222
|
-
)
|
|
223
|
-
if not response.ok:
|
|
224
|
-
raise APIError(f"API request failed: {response.status_code} {response.reason}")
|
|
225
|
-
return response.json()
|
|
226
|
-
except requests.RequestException as e:
|
|
227
|
-
raise APIError(f"Request failed: {str(e)}")
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
terrakio_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
terrakio_core/auth.py,sha256=Y3X5CcRUO7rAsrv995cSedZFKJAsW6ObDinYCbcQMpc,7605
|
|
3
|
-
terrakio_core/client.py,sha256=A8W-Tun8ZeMnQhr7d6i2ekyl4sylWTVq5amVLUhV6kE,36446
|
|
4
|
-
terrakio_core/config.py,sha256=AwJ1VgR5K7N32XCU5k7_Dp1nIv_FYt8MBonq9yKlGzA,2658
|
|
5
|
-
terrakio_core/dataset_management.py,sha256=hhO35fwStS6HYFQdKP9wkr3DxHgjvpctmIU8UWH6w6U,8742
|
|
6
|
-
terrakio_core/exceptions.py,sha256=9S-I20-QiDRj1qgjFyYUwYM7BLic_bxurcDOIm2Fu_0,410
|
|
7
|
-
terrakio_core/mass_stats.py,sha256=AqYJsd6nqo2BDh4vEPUDgsv4T0UR1_TPDoXa3WO3gTU,9284
|
|
8
|
-
terrakio_core/user_management.py,sha256=MMNWkz0V_9X7ZYjjteuRU4H4W3F16iuQw1dpA2wVTGg,7400
|
|
9
|
-
terrakio_core-0.2.1.dist-info/METADATA,sha256=n1judXAN5fxpx5jDOM6fIVNJXBeGkaghGwwdOuZH-3U,1518
|
|
10
|
-
terrakio_core-0.2.1.dist-info/WHEEL,sha256=QZxptf4Y1BKFRCEDxD4h2V0mBFQOVFLFEpvxHmIs52A,91
|
|
11
|
-
terrakio_core-0.2.1.dist-info/top_level.txt,sha256=5cBj6O7rNWyn97ND4YuvvXm0Crv4RxttT4JZvNdOG6Q,14
|
|
12
|
-
terrakio_core-0.2.1.dist-info/RECORD,,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
terrakio_core
|