terrakio-core 0.2.2__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.

@@ -1,9 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: terrakio-core
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Core components for Terrakio API clients
5
- Home-page: https://github.com/HaizeaAnalytics/terrakio-python-api
6
- Author: Yupeng Chao
7
5
  Author-email: Yupeng Chao <yupeng@haizea.com.au>
8
6
  Project-URL: Homepage, https://github.com/HaizeaAnalytics/terrakio-python-api
9
7
  Project-URL: Bug Tracker, https://github.com/HaizeaAnalytics/terrakio-python-api/issues
@@ -15,7 +13,7 @@ Classifier: Programming Language :: Python :: 3.10
15
13
  Classifier: License :: OSI Approved :: MIT License
16
14
  Classifier: Operating System :: OS Independent
17
15
  Classifier: Development Status :: 4 - Beta
18
- Requires-Python: >=3.7
16
+ Requires-Python: >3.11
19
17
  Description-Content-Type: text/markdown
20
18
  Requires-Dist: requests>=2.25.0
21
19
  Requires-Dist: aiohttp>=3.8.0
@@ -23,9 +21,6 @@ Requires-Dist: pyyaml>=5.1
23
21
  Requires-Dist: xarray>=2023.1.0
24
22
  Requires-Dist: shapely>=2.0.0
25
23
  Requires-Dist: geopandas>=0.13.0
26
- Dynamic: author
27
- Dynamic: home-page
28
- Dynamic: requires-python
29
24
 
30
25
  # Terrakio Core
31
26
 
@@ -0,0 +1,4 @@
1
+ terrakio_core-0.2.3.dist-info/METADATA,sha256=y2lq4MvHKznM_bVtqtlrTW92lVpaOO9MpRz-e2wPVPQ,1405
2
+ terrakio_core-0.2.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
3
+ terrakio_core-0.2.3.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
+ terrakio_core-0.2.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.8.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
terrakio_core/__init__.py DELETED
File without changes
terrakio_core/auth.py DELETED
@@ -1,238 +0,0 @@
1
- import requests
2
- from typing import Optional, Dict, Any
3
- from .exceptions import APIError, ConfigurationError
4
-
5
- class AuthClient:
6
- def __init__(self, base_url: str = "https://dev-au.terrak.io",
7
- verify: bool = True, timeout: int = 60):
8
- """
9
- Initialize the Authentication Client for Terrakio API.
10
-
11
- Args:
12
- base_url: Authentication API base URL
13
- verify: Verify SSL certificates
14
- timeout: Request timeout in seconds
15
- """
16
- self.base_url = base_url.rstrip('/')
17
- self.verify = verify
18
- self.timeout = timeout
19
- self.session = requests.Session()
20
- self.session.headers.update({
21
- 'Content-Type': 'application/json'
22
- })
23
- self.token = None
24
- self.api_key = None
25
-
26
- def signup(self, email: str, password: str) -> Dict[str, Any]:
27
- """
28
- Register a new user account.
29
-
30
- Args:
31
- email: User email address
32
- password: User password
33
-
34
- Returns:
35
- API response data
36
-
37
- Raises:
38
- APIError: If signup fails
39
- """
40
- endpoint = f"{self.base_url}/users/signup"
41
-
42
- payload = {
43
- "email": email,
44
- "password": password
45
- }
46
- print("the payload is ", payload)
47
- print("the endpoint is ", endpoint)
48
- try:
49
- response = self.session.post(
50
- endpoint,
51
- json=payload,
52
- verify=self.verify,
53
- timeout=self.timeout
54
- )
55
- print("the response is ", response)
56
- if not response.ok:
57
- error_msg = f"Signup failed: {response.status_code} {response.reason}"
58
- try:
59
- error_data = response.json()
60
- if "detail" in error_data:
61
- error_msg += f" - {error_data['detail']}"
62
- except:
63
- pass
64
- raise APIError(error_msg)
65
-
66
- return response.json()
67
- except requests.RequestException as e:
68
- raise APIError(f"Signup request failed: {str(e)}")
69
-
70
- def login(self, email: str, password: str) -> str:
71
- """
72
- Log in and obtain authentication token.
73
-
74
- Args:
75
- email: User email address
76
- password: User password
77
-
78
- Returns:
79
- Authentication token
80
-
81
- Raises:
82
- APIError: If login fails
83
- """
84
- endpoint = f"{self.base_url}/users/login"
85
-
86
- payload = {
87
- "email": email,
88
- "password": password
89
- }
90
-
91
- try:
92
- response = self.session.post(
93
- endpoint,
94
- json=payload,
95
- verify=self.verify,
96
- timeout=self.timeout
97
- )
98
-
99
- if not response.ok:
100
- error_msg = f"Login failed: {response.status_code} {response.reason}"
101
- try:
102
- error_data = response.json()
103
- if "detail" in error_data:
104
- error_msg += f" - {error_data['detail']}"
105
- except:
106
- pass
107
- raise APIError(error_msg)
108
-
109
- result = response.json()
110
- self.token = result.get("token")
111
-
112
- # Update session with authorization header
113
- if self.token:
114
- self.session.headers.update({
115
- "Authorization": self.token
116
- })
117
-
118
- return self.token
119
- except requests.RequestException as e:
120
- raise APIError(f"Login request failed: {str(e)}")
121
-
122
- def refresh_api_key(self) -> str:
123
- """
124
- Generate or refresh API key.
125
-
126
- Returns:
127
- API key
128
-
129
- Raises:
130
- ConfigurationError: If not authenticated
131
- APIError: If refresh fails
132
- """
133
- if not self.token:
134
- raise ConfigurationError("Not authenticated. Call login() first.")
135
-
136
- endpoint = f"{self.base_url}/users/refresh_key"
137
-
138
- try:
139
- # Use session with updated headers from login
140
- response = self.session.post(
141
- endpoint,
142
- verify=self.verify,
143
- timeout=self.timeout
144
- )
145
-
146
- if not response.ok:
147
- error_msg = f"API key generation failed: {response.status_code} {response.reason}"
148
- try:
149
- error_data = response.json()
150
- if "detail" in error_data:
151
- error_msg += f" - {error_data['detail']}"
152
- except:
153
- pass
154
- raise APIError(error_msg)
155
-
156
- result = response.json()
157
- self.api_key = result.get("apiKey")
158
- return self.api_key
159
- except requests.RequestException as e:
160
- raise APIError(f"API key refresh request failed: {str(e)}")
161
-
162
- def view_api_key(self) -> str:
163
- """
164
- Retrieve current API key.
165
-
166
- Returns:
167
- API key
168
-
169
- Raises:
170
- ConfigurationError: If not authenticated
171
- APIError: If retrieval fails
172
- """
173
- if not self.token:
174
- raise ConfigurationError("Not authenticated. Call login() first.")
175
-
176
- endpoint = f"{self.base_url}/users/key"
177
-
178
- try:
179
- # Use session with updated headers from login
180
- response = self.session.get(
181
- endpoint,
182
- verify=self.verify,
183
- timeout=self.timeout
184
- )
185
-
186
- if not response.ok:
187
- error_msg = f"Failed to retrieve API key: {response.status_code} {response.reason}"
188
- try:
189
- error_data = response.json()
190
- if "detail" in error_data:
191
- error_msg += f" - {error_data['detail']}"
192
- except:
193
- pass
194
- raise APIError(error_msg)
195
-
196
- result = response.json()
197
- self.api_key = result.get("apiKey")
198
- return self.api_key
199
- except requests.RequestException as e:
200
- raise APIError(f"API key retrieval request failed: {str(e)}")
201
-
202
- def get_user_info(self) -> Dict[str, Any]:
203
- """
204
- Retrieve the current user's information.
205
-
206
- Returns:
207
- User information data
208
-
209
- Raises:
210
- ConfigurationError: If not authenticated
211
- APIError: If retrieval fails
212
- """
213
- if not self.token:
214
- raise ConfigurationError("Not authenticated. Call login() first.")
215
-
216
- endpoint = f"{self.base_url}/users/info"
217
-
218
- try:
219
- # Use session with updated headers from login
220
- response = self.session.get(
221
- endpoint,
222
- verify=self.verify,
223
- timeout=self.timeout
224
- )
225
-
226
- if not response.ok:
227
- error_msg = f"Failed to retrieve user info: {response.status_code} {response.reason}"
228
- try:
229
- error_data = response.json()
230
- if "detail" in error_data:
231
- error_msg += f" - {error_data['detail']}"
232
- except:
233
- pass
234
- raise APIError(error_msg)
235
-
236
- return response.json()
237
- except requests.RequestException as e:
238
- raise APIError(f"User info retrieval request failed: {str(e)}")