geobox 1.4.1__py3-none-any.whl → 2.0.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.
- geobox/__init__.py +2 -2
- geobox/aio/__init__.py +63 -0
- geobox/aio/api.py +2640 -0
- geobox/aio/apikey.py +263 -0
- geobox/aio/attachment.py +339 -0
- geobox/aio/base.py +262 -0
- geobox/aio/basemap.py +196 -0
- geobox/aio/dashboard.py +342 -0
- geobox/aio/feature.py +527 -0
- geobox/aio/field.py +321 -0
- geobox/aio/file.py +522 -0
- geobox/aio/layout.py +341 -0
- geobox/aio/log.py +145 -0
- geobox/aio/map.py +1034 -0
- geobox/aio/model3d.py +415 -0
- geobox/aio/mosaic.py +696 -0
- geobox/aio/plan.py +315 -0
- geobox/aio/query.py +702 -0
- geobox/aio/raster.py +869 -0
- geobox/aio/route.py +63 -0
- geobox/aio/scene.py +342 -0
- geobox/aio/settings.py +194 -0
- geobox/aio/task.py +402 -0
- geobox/aio/tile3d.py +339 -0
- geobox/aio/tileset.py +672 -0
- geobox/aio/usage.py +243 -0
- geobox/aio/user.py +507 -0
- geobox/aio/vectorlayer.py +1363 -0
- geobox/aio/version.py +273 -0
- geobox/aio/view.py +983 -0
- geobox/aio/workflow.py +341 -0
- geobox/api.py +14 -13
- geobox/apikey.py +28 -1
- geobox/attachment.py +27 -1
- geobox/base.py +4 -4
- geobox/basemap.py +30 -1
- geobox/dashboard.py +27 -0
- geobox/feature.py +33 -13
- geobox/field.py +33 -21
- geobox/file.py +40 -46
- geobox/layout.py +28 -1
- geobox/log.py +31 -7
- geobox/map.py +56 -5
- geobox/model3d.py +98 -19
- geobox/mosaic.py +47 -7
- geobox/plan.py +29 -3
- geobox/query.py +41 -5
- geobox/raster.py +45 -13
- geobox/scene.py +26 -0
- geobox/settings.py +30 -1
- geobox/task.py +28 -6
- geobox/tile3d.py +27 -1
- geobox/tileset.py +26 -5
- geobox/usage.py +32 -1
- geobox/user.py +62 -6
- geobox/utils.py +34 -0
- geobox/vectorlayer.py +59 -4
- geobox/version.py +25 -1
- geobox/view.py +54 -15
- geobox/workflow.py +27 -1
- {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/METADATA +4 -1
- geobox-2.0.0.dist-info/RECORD +68 -0
- geobox-1.4.1.dist-info/RECORD +0 -38
- {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/WHEEL +0 -0
- {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/licenses/LICENSE +0 -0
- {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/top_level.txt +0 -0
geobox/aio/api.py
ADDED
|
@@ -0,0 +1,2640 @@
|
|
|
1
|
+
import aiohttp
|
|
2
|
+
import asyncio
|
|
3
|
+
import logging
|
|
4
|
+
import os
|
|
5
|
+
from urllib.parse import urljoin
|
|
6
|
+
from typing import Dict, List, Union, Any
|
|
7
|
+
from datetime import datetime
|
|
8
|
+
|
|
9
|
+
from ..api import GeoboxClient as SyncGeoboxClient
|
|
10
|
+
from .vectorlayer import VectorLayer, LayerType
|
|
11
|
+
from .feature import Feature
|
|
12
|
+
from .file import File
|
|
13
|
+
from .task import Task
|
|
14
|
+
from .view import VectorLayerView
|
|
15
|
+
from .tileset import Tileset
|
|
16
|
+
from .raster import Raster
|
|
17
|
+
from .mosaic import Mosaic
|
|
18
|
+
from .model3d import Model
|
|
19
|
+
from .map import Map
|
|
20
|
+
from .user import User, UserRole, UserStatus, Session
|
|
21
|
+
from .query import Query
|
|
22
|
+
from .workflow import Workflow
|
|
23
|
+
from .layout import Layout
|
|
24
|
+
from .version import VectorLayerVersion
|
|
25
|
+
from .tile3d import Tile3d
|
|
26
|
+
from .settings import SystemSettings
|
|
27
|
+
from .scene import Scene
|
|
28
|
+
from .route import Routing
|
|
29
|
+
from .plan import Plan
|
|
30
|
+
from .dashboard import Dashboard
|
|
31
|
+
from .basemap import Basemap
|
|
32
|
+
from .attachment import Attachment
|
|
33
|
+
from .apikey import ApiKey
|
|
34
|
+
from .log import Log
|
|
35
|
+
from .usage import Usage, UsageScale, UsageParam
|
|
36
|
+
from ..exception import AuthenticationError, ApiRequestError, NotFoundError, ValidationError, ServerError, AuthorizationError
|
|
37
|
+
from ..utils import join_url_params
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
logger = logging.getLogger(__name__)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class HttpMethods:
|
|
44
|
+
GET = 'GET'
|
|
45
|
+
PUT = 'PUT'
|
|
46
|
+
POST = 'POST'
|
|
47
|
+
DELETE = 'DELETE'
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class AsyncRequestSession:
|
|
51
|
+
"""An async session class that maintains headers and authentication state."""
|
|
52
|
+
|
|
53
|
+
def __init__(self, access_token=None):
|
|
54
|
+
"""
|
|
55
|
+
Initialize the session with authentication.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
access_token (str, optional): Bearer token for authentication
|
|
59
|
+
"""
|
|
60
|
+
self.access_token = access_token
|
|
61
|
+
self.headers = {
|
|
62
|
+
'Content-Type': 'application/json',
|
|
63
|
+
'Accept': 'application/json'
|
|
64
|
+
}
|
|
65
|
+
if self.access_token:
|
|
66
|
+
self.headers['Authorization'] = f'Bearer {self.access_token}'
|
|
67
|
+
self.session = None
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
async def __aenter__(self):
|
|
71
|
+
self.session = aiohttp.ClientSession(headers=self.headers)
|
|
72
|
+
return self
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
76
|
+
if self.session:
|
|
77
|
+
await self.session.close()
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def update_access_token(self, access_token: str) -> None:
|
|
81
|
+
"""
|
|
82
|
+
Update the access token of the session.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
access_token (str): The new access token
|
|
86
|
+
"""
|
|
87
|
+
self.access_token = access_token
|
|
88
|
+
self.headers['Authorization'] = f'Bearer {self.access_token}'
|
|
89
|
+
if self.session:
|
|
90
|
+
self.session.headers.update(self.headers)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _manage_headers_for_request(self, files=None, is_json=True) -> str:
|
|
94
|
+
"""
|
|
95
|
+
Manages headers for different types of requests.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
files (dict, optional): Files to upload
|
|
99
|
+
is_json (bool, optional): Whether payload is JSON
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
str: Original content type if it was modified
|
|
103
|
+
"""
|
|
104
|
+
original_content_type = None
|
|
105
|
+
|
|
106
|
+
if files:
|
|
107
|
+
# For file uploads, we need to completely avoid setting Content-Type
|
|
108
|
+
# Let aiohttp handle multipart boundary automatically
|
|
109
|
+
original_content_type = self.headers.get('Content-Type')
|
|
110
|
+
if 'Content-Type' in self.headers:
|
|
111
|
+
del self.headers['Content-Type']
|
|
112
|
+
elif not is_json:
|
|
113
|
+
original_content_type = self.headers.get('Content-Type')
|
|
114
|
+
self.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
|
115
|
+
|
|
116
|
+
return original_content_type
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class AsyncGeoboxClient(SyncGeoboxClient):
|
|
120
|
+
"""
|
|
121
|
+
An async class to interact with the Geobox API.
|
|
122
|
+
"""
|
|
123
|
+
def __init__(self,
|
|
124
|
+
host: str = 'https://api.geobox.ir',
|
|
125
|
+
ver: str = 'v1/',
|
|
126
|
+
username: str = None,
|
|
127
|
+
password: str = None,
|
|
128
|
+
access_token: str = None,
|
|
129
|
+
apikey: str = None):
|
|
130
|
+
"""
|
|
131
|
+
Constructs all the necessary attributes for the Api object.
|
|
132
|
+
"""
|
|
133
|
+
self.username = os.getenv('GEOBOX_USERNAME') if os.getenv('GEOBOX_USERNAME') else username
|
|
134
|
+
self.password = os.getenv('GEOBOX_PASSWORD') if os.getenv('GEOBOX_PASSWORD') else password
|
|
135
|
+
self.access_token = os.getenv('GEOBOX_ACCESS_TOKEN') if os.getenv('GEOBOX_ACCESS_TOKEN') else access_token
|
|
136
|
+
self.apikey = os.getenv('GEOBOX_APIKEY') if os.getenv('GEOBOX_APIKEY') else apikey
|
|
137
|
+
|
|
138
|
+
self.session = AsyncRequestSession(access_token=self.access_token)
|
|
139
|
+
|
|
140
|
+
host = host.lower()
|
|
141
|
+
self.base_url = urljoin(host, ver)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
if not self.access_token and not self.apikey:
|
|
145
|
+
if self.username and self.password:
|
|
146
|
+
pass
|
|
147
|
+
else:
|
|
148
|
+
raise ValueError("Please provide either username/password, apikey or access_token.")
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
async def __aenter__(self):
|
|
152
|
+
await self.session.__aenter__()
|
|
153
|
+
# Get access token if needed
|
|
154
|
+
try:
|
|
155
|
+
if not self.access_token and not self.apikey and self.username and self.password:
|
|
156
|
+
self.access_token = await self.get_access_token()
|
|
157
|
+
self.session.update_access_token(self.access_token)
|
|
158
|
+
return self
|
|
159
|
+
except Exception:
|
|
160
|
+
# If get_access_token fails, close the session before re-raising
|
|
161
|
+
await self.session.__aexit__(None, None, None)
|
|
162
|
+
raise
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
166
|
+
await self.session.__aexit__(exc_type, exc_val, exc_tb)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def __repr__(self) -> str:
|
|
170
|
+
"""
|
|
171
|
+
Return a string representation of the AsyncGeoboxClient object.
|
|
172
|
+
"""
|
|
173
|
+
if self.access_token and not self.username:
|
|
174
|
+
return f"AsyncGeoboxClient(access_token={self.access_token[:20] + '...' if len(self.access_token) > 20 else self.access_token})"
|
|
175
|
+
elif self.apikey:
|
|
176
|
+
return f"AsyncGeoboxClient(apikey={self.apikey[:20] + '...' if len(self.apikey) > 20 else self.apikey})"
|
|
177
|
+
elif self.username:
|
|
178
|
+
return f"AsyncGeoboxClient(username={self.username[:20] + '...' if len(self.username) > 20 else self.username})"
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
async def get_access_token(self) -> str:
|
|
182
|
+
"""
|
|
183
|
+
Obtains an access token using the username and password.
|
|
184
|
+
|
|
185
|
+
Returns:
|
|
186
|
+
str: The access token.
|
|
187
|
+
|
|
188
|
+
Raises:
|
|
189
|
+
AuthenticationError: If there is an error obtaining the access token.
|
|
190
|
+
"""
|
|
191
|
+
url = urljoin(self.base_url, "auth/token/")
|
|
192
|
+
data = {"username": self.username, "password": self.password}
|
|
193
|
+
|
|
194
|
+
try:
|
|
195
|
+
async with aiohttp.ClientSession() as temp_session:
|
|
196
|
+
async with temp_session.post(url, data=data) as response:
|
|
197
|
+
response_data = await response.json()
|
|
198
|
+
|
|
199
|
+
if response.status == 200:
|
|
200
|
+
return response_data["access_token"]
|
|
201
|
+
else:
|
|
202
|
+
raise AuthenticationError(f"Error obtaining access token: {response_data}")
|
|
203
|
+
except Exception as e:
|
|
204
|
+
raise AuthenticationError(f"Error obtaining access token: {e}")
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def _parse_error_message(self, response_data: dict) -> str:
|
|
208
|
+
"""
|
|
209
|
+
Parse error message from API response.
|
|
210
|
+
|
|
211
|
+
Args:
|
|
212
|
+
response_data (dict): The API response data.
|
|
213
|
+
|
|
214
|
+
Returns:
|
|
215
|
+
str: The parsed error message.
|
|
216
|
+
"""
|
|
217
|
+
detail = response_data.get('detail')
|
|
218
|
+
|
|
219
|
+
if not detail:
|
|
220
|
+
return str(response_data)
|
|
221
|
+
|
|
222
|
+
if isinstance(detail, list) and len(detail) == 1:
|
|
223
|
+
error = detail[0]
|
|
224
|
+
error_msg = error.get('msg', '')
|
|
225
|
+
loc = error.get('loc', [])
|
|
226
|
+
|
|
227
|
+
if loc and len(loc) >= 2:
|
|
228
|
+
return f'{error_msg}: "{loc[-1]}"'
|
|
229
|
+
return error_msg
|
|
230
|
+
|
|
231
|
+
if isinstance(detail, dict):
|
|
232
|
+
return detail.get('msg', str(detail))
|
|
233
|
+
|
|
234
|
+
return str(detail)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def _handle_error(self, status_code: int, response_data: dict) -> None:
|
|
238
|
+
"""
|
|
239
|
+
Handle API error response.
|
|
240
|
+
|
|
241
|
+
Args:
|
|
242
|
+
status_code (int): HTTP status code
|
|
243
|
+
response_data (dict): Response data
|
|
244
|
+
|
|
245
|
+
Raises:
|
|
246
|
+
Various error exceptions based on status code
|
|
247
|
+
"""
|
|
248
|
+
error_msg = self._parse_error_message(response_data)
|
|
249
|
+
|
|
250
|
+
if status_code == 401:
|
|
251
|
+
raise AuthenticationError(f'Invalid Authentication: {error_msg}')
|
|
252
|
+
elif status_code == 403:
|
|
253
|
+
raise AuthorizationError(f'Access forbidden: {error_msg}')
|
|
254
|
+
elif status_code == 404:
|
|
255
|
+
raise NotFoundError(f'Resource not found: {error_msg}')
|
|
256
|
+
elif status_code == 422:
|
|
257
|
+
raise ValidationError(error_msg)
|
|
258
|
+
elif status_code >= 500:
|
|
259
|
+
raise ServerError(error_msg)
|
|
260
|
+
else:
|
|
261
|
+
raise ApiRequestError(f"API request failed: {error_msg}")
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
async def _make_request(self,
|
|
265
|
+
method: str,
|
|
266
|
+
endpoint: str,
|
|
267
|
+
payload=None,
|
|
268
|
+
is_json=True,
|
|
269
|
+
files=None,
|
|
270
|
+
stream=None) -> Any:
|
|
271
|
+
"""
|
|
272
|
+
Makes an async HTTP request to the API.
|
|
273
|
+
"""
|
|
274
|
+
url = urljoin(self.base_url, endpoint)
|
|
275
|
+
|
|
276
|
+
if not self.access_token and self.apikey:
|
|
277
|
+
url = join_url_params(url, {'apikey': self.apikey})
|
|
278
|
+
|
|
279
|
+
try:
|
|
280
|
+
if files:
|
|
281
|
+
# For file uploads, use a fresh session to avoid header conflicts
|
|
282
|
+
# This is necessary because multipart uploads require specific Content-Type handling
|
|
283
|
+
file_headers = {}
|
|
284
|
+
if self.access_token:
|
|
285
|
+
file_headers['Authorization'] = f'Bearer {self.access_token}'
|
|
286
|
+
|
|
287
|
+
form = aiohttp.FormData()
|
|
288
|
+
for key, value in files.items():
|
|
289
|
+
if hasattr(value, 'read') and hasattr(value, 'name'):
|
|
290
|
+
# It's a file object, extract filename
|
|
291
|
+
filename = os.path.basename(value.name)
|
|
292
|
+
form.add_field(
|
|
293
|
+
name=key,
|
|
294
|
+
value=value,
|
|
295
|
+
filename=filename,
|
|
296
|
+
content_type="application/octet-stream"
|
|
297
|
+
)
|
|
298
|
+
else:
|
|
299
|
+
# It's just a value
|
|
300
|
+
form.add_field(
|
|
301
|
+
name=key,
|
|
302
|
+
value=value
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
# Use a temporary ClientSession for file uploads to avoid header conflicts
|
|
306
|
+
async with aiohttp.ClientSession() as temp_session:
|
|
307
|
+
async with temp_session.request(method, url, data=form, headers=file_headers) as response:
|
|
308
|
+
if stream:
|
|
309
|
+
response_data = response
|
|
310
|
+
else:
|
|
311
|
+
try:
|
|
312
|
+
response_data = await response.json()
|
|
313
|
+
except Exception:
|
|
314
|
+
response_data = None
|
|
315
|
+
status_code = response.status
|
|
316
|
+
|
|
317
|
+
elif is_json:
|
|
318
|
+
# Use the existing session and header management for JSON requests
|
|
319
|
+
original_content_type = self.session._manage_headers_for_request(files, is_json)
|
|
320
|
+
headers = self.session.headers.copy()
|
|
321
|
+
|
|
322
|
+
try:
|
|
323
|
+
async with self.session.session.request(method, url, json=payload, headers=headers) as response:
|
|
324
|
+
if stream:
|
|
325
|
+
response_data = response
|
|
326
|
+
else:
|
|
327
|
+
try:
|
|
328
|
+
response_data = await response.json()
|
|
329
|
+
except Exception:
|
|
330
|
+
response_data = None
|
|
331
|
+
status_code = response.status
|
|
332
|
+
finally:
|
|
333
|
+
if original_content_type:
|
|
334
|
+
self.session.headers['Content-Type'] = original_content_type
|
|
335
|
+
|
|
336
|
+
else:
|
|
337
|
+
# Use the existing session and header management for form data
|
|
338
|
+
original_content_type = self.session._manage_headers_for_request(files, is_json)
|
|
339
|
+
headers = self.session.headers.copy()
|
|
340
|
+
|
|
341
|
+
try:
|
|
342
|
+
async with self.session.session.request(method, url, data=payload, headers=headers) as response:
|
|
343
|
+
if stream:
|
|
344
|
+
response_data = response
|
|
345
|
+
else:
|
|
346
|
+
try:
|
|
347
|
+
response_data = await response.json()
|
|
348
|
+
except Exception:
|
|
349
|
+
response_data = None
|
|
350
|
+
status_code = response.status
|
|
351
|
+
finally:
|
|
352
|
+
if original_content_type:
|
|
353
|
+
self.session.headers['Content-Type'] = original_content_type
|
|
354
|
+
|
|
355
|
+
except asyncio.TimeoutError as e:
|
|
356
|
+
raise ApiRequestError(f"Request timed out: {e}")
|
|
357
|
+
except aiohttp.ClientError as e:
|
|
358
|
+
raise ApiRequestError(f"Request failed: {e}")
|
|
359
|
+
|
|
360
|
+
# Handle error responses
|
|
361
|
+
if status_code in [401, 403, 404, 422, 500]:
|
|
362
|
+
self._handle_error(status_code, response_data if isinstance(response_data, dict) else {})
|
|
363
|
+
|
|
364
|
+
# Log success responses
|
|
365
|
+
if status_code == 200:
|
|
366
|
+
logger.info("Request successful: Status code 200")
|
|
367
|
+
elif status_code == 201:
|
|
368
|
+
logger.info("Resource created successfully: Status code 201")
|
|
369
|
+
elif status_code == 202:
|
|
370
|
+
logger.info("Request accepted successfully: Status code 202")
|
|
371
|
+
elif status_code == 203:
|
|
372
|
+
logger.info("Non-authoritative information: Status code 203")
|
|
373
|
+
elif status_code == 204:
|
|
374
|
+
logger.info("Deleted, operation successful: Status code 204")
|
|
375
|
+
|
|
376
|
+
return response_data
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
async def get(self, endpoint: str, stream: bool = False) -> Dict:
|
|
380
|
+
"""
|
|
381
|
+
Sends a GET request to the API.
|
|
382
|
+
|
|
383
|
+
Args:
|
|
384
|
+
endpoint (str): The API endpoint.
|
|
385
|
+
stream (bool): Whether to stream the response.
|
|
386
|
+
|
|
387
|
+
Returns:
|
|
388
|
+
Dict: The response data.
|
|
389
|
+
"""
|
|
390
|
+
return await self._make_request(HttpMethods.GET, endpoint, stream=stream)
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
async def post(self, endpoint: str, payload: Dict = None, is_json: bool = True, files=None) -> Dict:
|
|
394
|
+
"""
|
|
395
|
+
Sends a POST request to the API.
|
|
396
|
+
|
|
397
|
+
Args:
|
|
398
|
+
endpoint (str): The API endpoint.
|
|
399
|
+
payload (Dict, optional): The data to send with the request.
|
|
400
|
+
is_json (bool, optional): Whether the payload is in JSON format.
|
|
401
|
+
files (dict, optional): Files to upload.
|
|
402
|
+
|
|
403
|
+
Returns:
|
|
404
|
+
Dict: The response data.
|
|
405
|
+
"""
|
|
406
|
+
return await self._make_request(HttpMethods.POST, endpoint, payload, is_json, files=files)
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
async def put(self, endpoint: str, payload: Dict, is_json: bool = True) -> Dict:
|
|
410
|
+
"""
|
|
411
|
+
Sends a PUT request to the API.
|
|
412
|
+
|
|
413
|
+
Args:
|
|
414
|
+
endpoint (str): The API endpoint.
|
|
415
|
+
payload (Dict): The data to send with the request.
|
|
416
|
+
is_json (bool, optional): Whether the payload is in JSON format.
|
|
417
|
+
|
|
418
|
+
Returns:
|
|
419
|
+
Dict: The response data.
|
|
420
|
+
"""
|
|
421
|
+
return await self._make_request(HttpMethods.PUT, endpoint, payload, is_json)
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
async def delete(self, endpoint: str, payload: Dict = None, is_json: bool = True) -> Dict:
|
|
425
|
+
"""
|
|
426
|
+
Sends a DELETE request to the API.
|
|
427
|
+
|
|
428
|
+
Args:
|
|
429
|
+
endpoint (str): The API endpoint.
|
|
430
|
+
payload (Dict, optional): The data to send with the request.
|
|
431
|
+
is_json (bool, optional): Whether the payload is in JSON format.
|
|
432
|
+
|
|
433
|
+
Returns:
|
|
434
|
+
Dict: The response data.
|
|
435
|
+
"""
|
|
436
|
+
return await self._make_request(HttpMethods.DELETE, endpoint, payload, is_json)
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
async def get_vectors(self, **kwargs) -> Union[List['VectorLayer'], int]:
|
|
440
|
+
"""
|
|
441
|
+
[async] Get a list of vector layers with optional filtering and pagination.
|
|
442
|
+
|
|
443
|
+
Keyword Args:
|
|
444
|
+
include_settings (bool): Whether to include layer settings. Default is False.
|
|
445
|
+
temporary (bool): Whether to return temporary layers, default is False
|
|
446
|
+
q (str): Query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
447
|
+
search (str): Search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
448
|
+
search_fields (str): Comma separated list of fields for searching
|
|
449
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
450
|
+
return_count (bool): Whether to return total count. default is False.
|
|
451
|
+
skip (int): Number of layers to skip. default is 0.
|
|
452
|
+
limit (int): Maximum number of layers to return. default is 10.
|
|
453
|
+
user_id (int): Specific user. privileges required.
|
|
454
|
+
shared (bool): Whether to return shared layers. default is False.
|
|
455
|
+
|
|
456
|
+
Returns:
|
|
457
|
+
List[VectorLayer] | int: A list of VectorLayer instances or the layers count if return_count is True.
|
|
458
|
+
|
|
459
|
+
Example:
|
|
460
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
461
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
462
|
+
>>> layers = await client.get_vectors(include_settings=True,
|
|
463
|
+
... skip=0,
|
|
464
|
+
... limit=100,
|
|
465
|
+
... return_count=False,
|
|
466
|
+
... search="my_layer",
|
|
467
|
+
... search_fields="name, description",
|
|
468
|
+
... order_by="name",
|
|
469
|
+
... shared=True)
|
|
470
|
+
"""
|
|
471
|
+
return await VectorLayer.get_vectors(self, **kwargs)
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
async def get_vector(self, uuid: str, user_id: int = None) -> 'VectorLayer':
|
|
475
|
+
"""
|
|
476
|
+
[async] Get a specific vector layer by its UUID.
|
|
477
|
+
|
|
478
|
+
Args:
|
|
479
|
+
uuid (str): The UUID of the layer to retrieve.
|
|
480
|
+
user_id (int, optional): Specific user. privileges required.
|
|
481
|
+
|
|
482
|
+
Returns:
|
|
483
|
+
VectorLayer: The requested layer instance.
|
|
484
|
+
|
|
485
|
+
Raises:
|
|
486
|
+
NotFoundError: If the layer with the specified UUID is not found.
|
|
487
|
+
|
|
488
|
+
Example:
|
|
489
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
490
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
491
|
+
>>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
492
|
+
"""
|
|
493
|
+
return await VectorLayer.get_vector(self, uuid, user_id)
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
async def get_vectors_by_ids(self, ids: List[int], user_id: int = None, include_settings: bool = False) -> List['VectorLayer']:
|
|
497
|
+
"""
|
|
498
|
+
[async] Get vector layers by their IDs.
|
|
499
|
+
|
|
500
|
+
Args:
|
|
501
|
+
ids (List[int]): The IDs of the layers to retrieve.
|
|
502
|
+
user_id (int, optional): Specific user. privileges required.
|
|
503
|
+
include_settings (bool, optional): Whether to include the layer settings. default is False.
|
|
504
|
+
|
|
505
|
+
Returns:
|
|
506
|
+
List[VectorLayer]: The list of VectorLayer instances.
|
|
507
|
+
|
|
508
|
+
Example:
|
|
509
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
510
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
511
|
+
>>> layers = await client.get_vectors_by_ids(ids=[1, 2, 3])
|
|
512
|
+
"""
|
|
513
|
+
return await VectorLayer.get_vectors_by_ids(self, ids, user_id, include_settings)
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
async def create_vector(self,
|
|
517
|
+
name: str,
|
|
518
|
+
layer_type: 'LayerType',
|
|
519
|
+
display_name: str = None,
|
|
520
|
+
description: str = None,
|
|
521
|
+
has_z: bool = False,
|
|
522
|
+
temporary: bool = False,
|
|
523
|
+
fields: List = None) -> 'VectorLayer':
|
|
524
|
+
"""
|
|
525
|
+
[async] Create a new vector layer.
|
|
526
|
+
|
|
527
|
+
Args:
|
|
528
|
+
name (str): The name of the layer.
|
|
529
|
+
layer_type (LayerType): The type of geometry to store.
|
|
530
|
+
display_name (str, optional): A human-readable name for the layer. default is None.
|
|
531
|
+
description (str, optional): A description of the layer. default is None.
|
|
532
|
+
has_z (bool, optional): Whether the layer includes Z coordinates. default is False.
|
|
533
|
+
temporary (bool, optional): Whether to create a temporary layer. temporary layers will be deleted after 24 hours. default is False.
|
|
534
|
+
fields (List, optional): List of field definitions for the layer. default is None.
|
|
535
|
+
|
|
536
|
+
Returns:
|
|
537
|
+
VectorLayer: The newly created layer instance.
|
|
538
|
+
|
|
539
|
+
Raises:
|
|
540
|
+
ValidationError: If the layer data is invalid.
|
|
541
|
+
|
|
542
|
+
Example:
|
|
543
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
544
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
545
|
+
>>> layer = await client.create_vector(name="my_layer",
|
|
546
|
+
... layer_type=LayerType.Point,
|
|
547
|
+
... display_name="My Layer",
|
|
548
|
+
... description="This is a description of my layer",
|
|
549
|
+
... has_z=False,
|
|
550
|
+
... fields=[{"name": "my_field", "datatype": "FieldTypeString"}])
|
|
551
|
+
"""
|
|
552
|
+
return await VectorLayer.create_vector(self, name=name, layer_type=layer_type, display_name=display_name, description=description, has_z=has_z, temporary=temporary, fields=fields)
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
async def get_vector_by_name(self, name: str, user_id: int = None) -> Union['VectorLayer', None]:
|
|
556
|
+
"""
|
|
557
|
+
[async] Get a vector layer by name
|
|
558
|
+
|
|
559
|
+
Args:
|
|
560
|
+
name (str): the name of the vector to get
|
|
561
|
+
user_id (int, optional): specific user. privileges required.
|
|
562
|
+
|
|
563
|
+
Returns:
|
|
564
|
+
VectorLayer | None: returns the vector if a vector matches the given name, else None
|
|
565
|
+
|
|
566
|
+
Example:
|
|
567
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
568
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
569
|
+
>>> layer = await client.get_vector_by_name(name='test')
|
|
570
|
+
"""
|
|
571
|
+
return await VectorLayer.get_vector_by_name(self, name, user_id)
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
async def get_files(self, **kwargs) -> Union[List['File'], int]:
|
|
575
|
+
"""
|
|
576
|
+
[async] Retrieves a list of files.
|
|
577
|
+
|
|
578
|
+
Keyword Args:
|
|
579
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
580
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
581
|
+
search_fields (str): comma separated list of fields for searching
|
|
582
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D.NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
583
|
+
return_count (bool): if true, the total number of results will be returned. default is False.
|
|
584
|
+
skip (int): number of results to skip. default is 0.
|
|
585
|
+
limit (int): number of results to return. default is 10.
|
|
586
|
+
user_id (int): filter by user id.
|
|
587
|
+
shared (bool): Whether to return shared files. default is False.
|
|
588
|
+
|
|
589
|
+
Returns:
|
|
590
|
+
List[File] | int: A list of File objects or the total number of results.
|
|
591
|
+
|
|
592
|
+
Example:
|
|
593
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
594
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
595
|
+
>>> files = await client.get_files(search_fields='name', search='GIS', order_by='name', skip=10, limit=10)
|
|
596
|
+
"""
|
|
597
|
+
return await File.get_files(self, **kwargs)
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
async def get_file(self, uuid: str) -> 'File':
|
|
601
|
+
"""
|
|
602
|
+
[async] Retrieves a file by its UUID.
|
|
603
|
+
|
|
604
|
+
Args:
|
|
605
|
+
uuid (str, optional): The UUID of the file.
|
|
606
|
+
|
|
607
|
+
Returns:
|
|
608
|
+
File: The retrieved file instance.
|
|
609
|
+
|
|
610
|
+
Raises:
|
|
611
|
+
NotFoundError: If the file with the specified UUID is not found.
|
|
612
|
+
|
|
613
|
+
Example:
|
|
614
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
615
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
616
|
+
>>> file = await client.get_file(uuid="12345678-1234-5678-1234-567812345678")
|
|
617
|
+
"""
|
|
618
|
+
return await File.get_file(self, uuid=uuid)
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
async def get_files_by_name(self, name: str, user_id: int = None) -> List['File']:
|
|
622
|
+
"""
|
|
623
|
+
[async] Get files by name
|
|
624
|
+
|
|
625
|
+
Args:
|
|
626
|
+
name (str): the name of the file to get
|
|
627
|
+
user_id (int, optional): specific user. privileges required.
|
|
628
|
+
|
|
629
|
+
Returns:
|
|
630
|
+
List[File]: returns files that matches the given name
|
|
631
|
+
|
|
632
|
+
Example:
|
|
633
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
634
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
635
|
+
>>> files = await client.get_files_by_name(name='test')
|
|
636
|
+
"""
|
|
637
|
+
return await File.get_files_by_name(self, name, user_id)
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
async def upload_file(self, path: str, user_id: int = None, scan_archive: bool = True) -> 'File':
|
|
641
|
+
"""
|
|
642
|
+
[async] Upload a file to the GeoBox API.
|
|
643
|
+
|
|
644
|
+
Args:
|
|
645
|
+
path (str): The path to the file to upload.
|
|
646
|
+
user_id (int, optional): specific user. privileges required.
|
|
647
|
+
scan_archive (bool, optional): Whether to scan the archive for layers. default: True
|
|
648
|
+
|
|
649
|
+
Returns:
|
|
650
|
+
File: The uploaded file instance.
|
|
651
|
+
|
|
652
|
+
Raises:
|
|
653
|
+
ValueError: If the file type is invalid.
|
|
654
|
+
FileNotFoundError: If the file does not exist.
|
|
655
|
+
|
|
656
|
+
Example:
|
|
657
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
658
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
659
|
+
>>> file = await client.upload_file(path='path/to/file.shp')
|
|
660
|
+
"""
|
|
661
|
+
return await File.upload_file(self, path=path, user_id=user_id, scan_archive=scan_archive)
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
async def get_tasks(self, **kwargs) -> Union[List['Task'], int]:
|
|
665
|
+
"""
|
|
666
|
+
[async] Get a list of tasks
|
|
667
|
+
|
|
668
|
+
Keyword Args:
|
|
669
|
+
state (TaskStatus): Available values : TaskStatus.PENDING, TaskStatus.PROGRESS, TaskStatus.SUCCESS, TaskStatus.FAILURE, TaskStatus.ABORTED
|
|
670
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
671
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
672
|
+
search_fields (str): comma separated list of fields for searching.
|
|
673
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
674
|
+
return_count (bool): The count of the tasks. default is False.
|
|
675
|
+
skip (int): The skip of the task. default is 0.
|
|
676
|
+
limit (int): The limit of the task. default is 10.
|
|
677
|
+
user_id (int): Specific user. privileges required.
|
|
678
|
+
shared (bool): Whether to return shared tasks. default is False.
|
|
679
|
+
|
|
680
|
+
Returns:
|
|
681
|
+
List[Task] | int: The list of task objects or the count of the tasks if return_count is True.
|
|
682
|
+
|
|
683
|
+
Example:
|
|
684
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
685
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
686
|
+
>>> tasks = await client.get_tasks()
|
|
687
|
+
"""
|
|
688
|
+
return await Task.get_tasks(self, **kwargs)
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
async def get_task(self, uuid: str) -> 'Task':
|
|
692
|
+
"""
|
|
693
|
+
[async] Gets a task.
|
|
694
|
+
|
|
695
|
+
Args:
|
|
696
|
+
uuid (str): The UUID of the task.
|
|
697
|
+
|
|
698
|
+
Returns:
|
|
699
|
+
Task: The task object.
|
|
700
|
+
|
|
701
|
+
Example:
|
|
702
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
703
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
704
|
+
>>> task = await client.get_task(uuid="12345678-1234-5678-1234-567812345678")
|
|
705
|
+
"""
|
|
706
|
+
return await Task.get_task(self, uuid)
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
async def get_views(self, **kwargs) -> Union[List['VectorLayerView'], int]:
|
|
710
|
+
"""
|
|
711
|
+
[async] Get vector layer views.
|
|
712
|
+
|
|
713
|
+
Keyword Args:
|
|
714
|
+
layer_id(int): The id of the layer.
|
|
715
|
+
include_settings(bool): Whether to include the settings of the layer. default is False.
|
|
716
|
+
q(str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
717
|
+
search(str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
718
|
+
search_fields(str): Comma separated list of fields for searching.
|
|
719
|
+
order_by(str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
720
|
+
return_count(bool): Whether to return the count of the layer views. default is False.
|
|
721
|
+
skip(int): The number of layer views to skip. minimum is 0.
|
|
722
|
+
limit(int): The maximum number of layer views to return. minimum is 1. default is 10.
|
|
723
|
+
user_id(int): Specific user. privileges required.
|
|
724
|
+
shared(bool): Whether to return shared views. default is False.
|
|
725
|
+
|
|
726
|
+
Returns:
|
|
727
|
+
list[VectorLayerView] | int: A list of VectorLayerView instances or the layer views count if return_count is True.
|
|
728
|
+
|
|
729
|
+
Example:
|
|
730
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
731
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
732
|
+
>>> views = await client.get_views(layer_id=1,
|
|
733
|
+
... include_settings=True,
|
|
734
|
+
... search="test",
|
|
735
|
+
... search_fields="name",
|
|
736
|
+
... order_by="name A",
|
|
737
|
+
... return_count=False,
|
|
738
|
+
... skip=0,
|
|
739
|
+
... limit=10,
|
|
740
|
+
... shared=True)
|
|
741
|
+
"""
|
|
742
|
+
return await VectorLayerView.get_views(self, **kwargs)
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
async def get_views_by_ids(self, ids: List[int], user_id: int = None, include_settings: bool = False) -> List['VectorLayerView']:
|
|
746
|
+
"""
|
|
747
|
+
[async] Get vector layer views by their IDs.
|
|
748
|
+
|
|
749
|
+
Args:
|
|
750
|
+
ids (List[int]): list of comma separated layer ids to be returned. e.g. 1, 2, 3
|
|
751
|
+
user_id (int, optional): specific user. privileges required.
|
|
752
|
+
include_settings (bool, optional): Whether to include the settings of the vector layer views. default is False.
|
|
753
|
+
|
|
754
|
+
Returns:
|
|
755
|
+
List[VectorLayerView]: A list of VectorLayerView instances.
|
|
756
|
+
|
|
757
|
+
Example:
|
|
758
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
759
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
760
|
+
>>> views = await client.get_views_by_ids(ids=[1,2,3])
|
|
761
|
+
"""
|
|
762
|
+
return await VectorLayerView.get_views_by_ids(self, ids, user_id, include_settings)
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
async def get_view(self, uuid: str) -> 'VectorLayerView':
|
|
766
|
+
"""
|
|
767
|
+
[async] Get a specific vector layer view by its UUID.
|
|
768
|
+
|
|
769
|
+
Args:
|
|
770
|
+
uuid (str): The UUID of the vector layer view.
|
|
771
|
+
user_id (int, optional): Specific user. privileges required.
|
|
772
|
+
|
|
773
|
+
Returns:
|
|
774
|
+
VectorLayerView: A VectorLayerView instance.
|
|
775
|
+
|
|
776
|
+
Example:
|
|
777
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
778
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
779
|
+
>>> view = await client.get_view(uuid="12345678-1234-5678-1234-567812345678")
|
|
780
|
+
"""
|
|
781
|
+
return await VectorLayerView.get_view(self, uuid)
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
async def get_view_by_name(self, name: str, user_id: int = None) -> Union['VectorLayerView', None]:
|
|
785
|
+
"""
|
|
786
|
+
[async] Get a view by name
|
|
787
|
+
|
|
788
|
+
Args:
|
|
789
|
+
name (str): the name of the view to get
|
|
790
|
+
user_id (int, optional): specific user. privileges required.
|
|
791
|
+
|
|
792
|
+
Returns:
|
|
793
|
+
VectorLayerView | None: returns the view if a view matches the given name, else None
|
|
794
|
+
|
|
795
|
+
Example:
|
|
796
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
797
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
798
|
+
>>> view = await client.get_view_by_name(name='test')
|
|
799
|
+
"""
|
|
800
|
+
return await VectorLayerView.get_view_by_name(self, name, user_id)
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
async def create_tileset(self, name: str, layers: List[Union['VectorLayer', 'VectorLayerView']], display_name: str = None, description: str = None,
|
|
804
|
+
min_zoom: int = None, max_zoom: int = None, user_id: int = None) -> 'Tileset':
|
|
805
|
+
"""
|
|
806
|
+
[async] Create a new tileset.
|
|
807
|
+
|
|
808
|
+
Args:
|
|
809
|
+
name (str): The name of the tileset.
|
|
810
|
+
layers (List['VectorLayer' | 'VectorLayerView']): list of vectorlayer and view objects to add to tileset.
|
|
811
|
+
display_name (str, optional): The display name of the tileset.
|
|
812
|
+
description (str, optional): The description of the tileset.
|
|
813
|
+
min_zoom (int, optional): The minimum zoom level of the tileset.
|
|
814
|
+
max_zoom (int, optional): The maximum zoom level of the tileset.
|
|
815
|
+
user_id (int, optional): Specific user. privileges required.
|
|
816
|
+
|
|
817
|
+
Returns:
|
|
818
|
+
Tileset: The created tileset instance.
|
|
819
|
+
|
|
820
|
+
Example:
|
|
821
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
822
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
823
|
+
>>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
824
|
+
>>> view = await client.get_view(uuid="12345678-1234-5678-1234-567812345678")
|
|
825
|
+
>>> tileset = await client.create_tileset(name="your_tileset_name",
|
|
826
|
+
... display_name="Your Tileset",
|
|
827
|
+
... description="Your description",
|
|
828
|
+
... min_zoom=0,
|
|
829
|
+
... max_zoom=14,
|
|
830
|
+
... layers=[layer, view])
|
|
831
|
+
"""
|
|
832
|
+
return await Tileset.create_tileset(api=self,
|
|
833
|
+
name=name,
|
|
834
|
+
layers=layers,
|
|
835
|
+
display_name=display_name,
|
|
836
|
+
description=description,
|
|
837
|
+
min_zoom=min_zoom,
|
|
838
|
+
max_zoom=max_zoom,
|
|
839
|
+
user_id=user_id)
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
async def get_tilesets(self, **kwargs) -> Union[List['Tileset'], int]:
|
|
843
|
+
"""
|
|
844
|
+
[async] Retrieves a list of tilesets.
|
|
845
|
+
|
|
846
|
+
Keyword Args:
|
|
847
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
848
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
849
|
+
search_fields (str): comma separated list of fields for searching.
|
|
850
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
851
|
+
return_count (bool): if True, returns the total number of tilesets matching the query. default is False.
|
|
852
|
+
skip (int): number of records to skip. default is 0.
|
|
853
|
+
limit (int): number of records to return. default is 10.
|
|
854
|
+
user_id (int): Specific user. privileges required.
|
|
855
|
+
shared (bool): Whether to return shared tilesets. default is False.
|
|
856
|
+
|
|
857
|
+
Returns:
|
|
858
|
+
List[Tileset] | int: A list of Tileset instances or the total number of tilesets
|
|
859
|
+
|
|
860
|
+
Example:
|
|
861
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
862
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
863
|
+
>>> tilesets = await client.get_tilesets(q="name LIKE '%your_tileset_name%'",
|
|
864
|
+
... order_by="name A",
|
|
865
|
+
... skip=0,
|
|
866
|
+
... limit=10,
|
|
867
|
+
... )
|
|
868
|
+
"""
|
|
869
|
+
return await Tileset.get_tilesets(self, **kwargs)
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
async def get_tilesets_by_ids(self, ids: List[int], user_id: int = None) -> List['Tileset']:
|
|
873
|
+
"""
|
|
874
|
+
[async] Retrieves a list of tilesets by their IDs.
|
|
875
|
+
|
|
876
|
+
Args:
|
|
877
|
+
ids (List[str]): The list of tileset IDs.
|
|
878
|
+
user_id (int, optional): Specific user. privileges required.
|
|
879
|
+
|
|
880
|
+
Returns:
|
|
881
|
+
List[Tileset]: A list of Tileset instances.
|
|
882
|
+
|
|
883
|
+
Example:
|
|
884
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
885
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
886
|
+
>>> tilesets = await client.get_tilesets_by_ids(ids=['123', '456'])
|
|
887
|
+
"""
|
|
888
|
+
return await Tileset.get_tilesets_by_ids(self, ids, user_id)
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
async def get_tileset(self, uuid: str) -> 'Tileset':
|
|
892
|
+
"""
|
|
893
|
+
[async] Retrieves a tileset by its UUID.
|
|
894
|
+
|
|
895
|
+
Args:
|
|
896
|
+
uuid (str): The UUID of the tileset.
|
|
897
|
+
|
|
898
|
+
Returns:
|
|
899
|
+
Tileset: The retrieved tileset instance.
|
|
900
|
+
|
|
901
|
+
Example:
|
|
902
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
903
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
904
|
+
>>> tileset = await client.get_tileset(uuid="12345678-1234-5678-1234-567812345678")
|
|
905
|
+
"""
|
|
906
|
+
return await Tileset.get_tileset(self, uuid)
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
async def get_tileset_by_name(self, name: str, user_id: int = None) -> Union['Tileset', None]:
|
|
910
|
+
"""
|
|
911
|
+
[async] Get a tileset by name
|
|
912
|
+
|
|
913
|
+
Args:
|
|
914
|
+
name (str): the name of the tileset to get
|
|
915
|
+
user_id (int, optional): specific user. privileges required.
|
|
916
|
+
|
|
917
|
+
Returns:
|
|
918
|
+
Tileset | None: returns the tileset if a tileset matches the given name, else None
|
|
919
|
+
|
|
920
|
+
Example:
|
|
921
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
922
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
923
|
+
>>> tileset = await client.get_tileset_by_name(name='test')
|
|
924
|
+
"""
|
|
925
|
+
return await Tileset.get_tileset_by_name(self, name, user_id)
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
async def get_rasters(self, **kwargs) -> Union[List['Raster'], int]:
|
|
929
|
+
"""
|
|
930
|
+
[async] Get all rasters.
|
|
931
|
+
|
|
932
|
+
Keyword Args:
|
|
933
|
+
terrain (bool): whether to get terrain rasters.
|
|
934
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
935
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
936
|
+
search_fields (str): comma separated list of fields for searching
|
|
937
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
938
|
+
return_count (bool): whether to return the total count of rasters. default is False.
|
|
939
|
+
skip (int): number of rasters to skip. minimum is 0.
|
|
940
|
+
limit (int): number of rasters to return. minimum is 1.
|
|
941
|
+
user_id (int): user id to show the rasters of the user. privileges required.
|
|
942
|
+
shared (bool): whether to return shared rasters. default is False.
|
|
943
|
+
|
|
944
|
+
Returns:
|
|
945
|
+
List[Raster] | int: A list of Raster objects or the total count of rasters.
|
|
946
|
+
|
|
947
|
+
Example:
|
|
948
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
949
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
950
|
+
>>> rasters = await client.get_rasters(terrain=True, q="name LIKE '%GIS%'")
|
|
951
|
+
"""
|
|
952
|
+
return await Raster.get_rasters(self, **kwargs)
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
async def get_rasters_by_ids(self, ids: List[int], user_id: int = None) -> List['Raster']:
|
|
956
|
+
"""
|
|
957
|
+
[async] Get rasters by their IDs.
|
|
958
|
+
|
|
959
|
+
Args:
|
|
960
|
+
ids (List[str]): The IDs of the rasters.
|
|
961
|
+
user_id (int, optional): specific user. privileges required.
|
|
962
|
+
|
|
963
|
+
Returns:
|
|
964
|
+
List['Raster']: A list of Raster objects.
|
|
965
|
+
|
|
966
|
+
Example:
|
|
967
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
968
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
969
|
+
>>> rasters = await client.get_rasters_by_ids(ids=['123', '456'])
|
|
970
|
+
"""
|
|
971
|
+
return await Raster.get_rasters_by_ids(self, ids, user_id)
|
|
972
|
+
|
|
973
|
+
|
|
974
|
+
async def get_raster(self, uuid: str) -> 'Raster':
|
|
975
|
+
"""
|
|
976
|
+
[async] Get a raster by its UUID.
|
|
977
|
+
|
|
978
|
+
Args:
|
|
979
|
+
uuid (str): The UUID of the raster.
|
|
980
|
+
user_id (int, optional): specific user. privileges required.
|
|
981
|
+
|
|
982
|
+
Returns:
|
|
983
|
+
Raster: A Raster object.
|
|
984
|
+
|
|
985
|
+
Example:
|
|
986
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
987
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
988
|
+
>>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678")
|
|
989
|
+
"""
|
|
990
|
+
return await Raster.get_raster(self, uuid)
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
async def get_raster_by_name(self, name: str, user_id: int = None) -> Union['Raster', None]:
|
|
994
|
+
"""
|
|
995
|
+
[async] Get a raster by name
|
|
996
|
+
|
|
997
|
+
Args:
|
|
998
|
+
name (str): the name of the raster to get
|
|
999
|
+
user_id (int, optional): specific user. privileges required.
|
|
1000
|
+
|
|
1001
|
+
Returns:
|
|
1002
|
+
Raster | None: returns the raster if a raster matches the given name, else None
|
|
1003
|
+
|
|
1004
|
+
Example:
|
|
1005
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1006
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1007
|
+
>>> raster = await client.get_raster_by_name(name='test')
|
|
1008
|
+
"""
|
|
1009
|
+
return await Raster.get_raster_by_name(self, name, user_id)
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
async def get_mosaics(self, **kwargs) -> Union[List['Mosaic'], int]:
|
|
1013
|
+
"""
|
|
1014
|
+
[async] Get a list of mosaics.
|
|
1015
|
+
|
|
1016
|
+
Keyword Args:
|
|
1017
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'".
|
|
1018
|
+
seacrh (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
1019
|
+
search_fields (str): comma separated list of fields for searching.
|
|
1020
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
1021
|
+
return_count (bool): if true, the number of mosaics will be returned.
|
|
1022
|
+
skip (int): number of mosaics to skip. minimum value is 0.
|
|
1023
|
+
limit (int): maximum number of mosaics to return. minimum value is 1.
|
|
1024
|
+
user_id (int): specific user. privileges required.
|
|
1025
|
+
shared (bool): Whether to return shared mosaics. default is False.
|
|
1026
|
+
|
|
1027
|
+
Returns:
|
|
1028
|
+
List['Mosaic'] | int: A list of Mosaic instances or the number of mosaics.
|
|
1029
|
+
|
|
1030
|
+
Example:
|
|
1031
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1032
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1033
|
+
>>> mosaics = await client.get_mosaics(q="name LIKE '%GIS%'")
|
|
1034
|
+
"""
|
|
1035
|
+
return await Mosaic.get_mosaics(self, **kwargs)
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
async def get_mosaics_by_ids(self, ids: List[int], user_id: int = None) -> List['Mosaic']:
|
|
1039
|
+
"""
|
|
1040
|
+
[async] Get mosaics by their IDs.
|
|
1041
|
+
|
|
1042
|
+
Args:
|
|
1043
|
+
ids (List[str]): The IDs of the mosaics.
|
|
1044
|
+
user_id (int, optional): specific user. privileges required.
|
|
1045
|
+
|
|
1046
|
+
Returns:
|
|
1047
|
+
List[Mosaic]: A list of Mosaic instances.
|
|
1048
|
+
|
|
1049
|
+
Example:
|
|
1050
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1051
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1052
|
+
>>> mosaics = await client.get_mosaics_by_ids(ids=['1, 2, 3'])
|
|
1053
|
+
"""
|
|
1054
|
+
return await Mosaic.get_mosaics_by_ids(self, ids, user_id)
|
|
1055
|
+
|
|
1056
|
+
|
|
1057
|
+
async def create_mosaic(self,
|
|
1058
|
+
name:str,
|
|
1059
|
+
display_name: str = None,
|
|
1060
|
+
description: str = None,
|
|
1061
|
+
pixel_selection: str = None,
|
|
1062
|
+
min_zoom: int = None,
|
|
1063
|
+
user_id: int = None) -> 'Mosaic':
|
|
1064
|
+
"""
|
|
1065
|
+
[async] Create New Raster Mosaic
|
|
1066
|
+
|
|
1067
|
+
Args:
|
|
1068
|
+
name (str): The name of the mosaic.
|
|
1069
|
+
display_name (str, optional): The display name of the mosaic.
|
|
1070
|
+
description (str, optional): The description of the mosaic.
|
|
1071
|
+
pixel_selection (str, optional): The pixel selection of the mosaic.
|
|
1072
|
+
min_zoom (int, optional): The minimum zoom of the mosaic.
|
|
1073
|
+
user_id (int, optional): specific user. privileges required.
|
|
1074
|
+
|
|
1075
|
+
Returns:
|
|
1076
|
+
Mosaic: The created mosaic.
|
|
1077
|
+
|
|
1078
|
+
Example:
|
|
1079
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1080
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1081
|
+
>>> mosaic = await client.create_mosaic(name='mosaic_name')
|
|
1082
|
+
"""
|
|
1083
|
+
return await Mosaic.create_mosaic(self, name, display_name, description, pixel_selection, min_zoom, user_id)
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
async def get_mosaic(self, uuid: str, user_id: int = None) -> 'Mosaic':
|
|
1087
|
+
"""
|
|
1088
|
+
[async] Get a mosaic by uuid.
|
|
1089
|
+
|
|
1090
|
+
Args:
|
|
1091
|
+
uuid (str): The UUID of the mosaic.
|
|
1092
|
+
user_id (int, optional): specific user. privileges required.
|
|
1093
|
+
|
|
1094
|
+
Returns:
|
|
1095
|
+
Mosaic: The mosaic object.
|
|
1096
|
+
|
|
1097
|
+
Example:
|
|
1098
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1099
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1100
|
+
>>> mosaic = await client.get_mosaic(uuid="12345678-1234-5678-1234-567812345678")
|
|
1101
|
+
"""
|
|
1102
|
+
return await Mosaic.get_mosaic(self, uuid, user_id)
|
|
1103
|
+
|
|
1104
|
+
|
|
1105
|
+
async def get_mosaic_by_name(self, name: str, user_id: int = None) -> Union['Mosaic', None]:
|
|
1106
|
+
"""
|
|
1107
|
+
[async] Get a mosaic by name
|
|
1108
|
+
|
|
1109
|
+
Args:
|
|
1110
|
+
name (str): the name of the mosaic to get
|
|
1111
|
+
user_id (int, optional): specific user. privileges required.
|
|
1112
|
+
|
|
1113
|
+
Returns:
|
|
1114
|
+
Mosaic | None: returns the mosaic if a mosaic matches the given name, else None
|
|
1115
|
+
|
|
1116
|
+
Example:
|
|
1117
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1118
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1119
|
+
>>> mosaic = await client.get_mosaic_by_name(name='test')
|
|
1120
|
+
"""
|
|
1121
|
+
return await Mosaic.get_mosaic_by_name(self, name, user_id)
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
async def get_models(self, **kwargs) -> Union[List['Model'], int]:
|
|
1125
|
+
"""
|
|
1126
|
+
[async] Get a list of models with optional filtering and pagination.
|
|
1127
|
+
|
|
1128
|
+
Keyword Args:
|
|
1129
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'".
|
|
1130
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
1131
|
+
search_fields (str): comma separated list of fields for searching.
|
|
1132
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
1133
|
+
return_count (bool): whether to return total count. default is False.
|
|
1134
|
+
skip (int): number of models to skip. default is 0.
|
|
1135
|
+
limit (int): maximum number of models to return. default is 10.
|
|
1136
|
+
user_id (int): specific user. privileges required.
|
|
1137
|
+
shared (bool): Whether to return shared models. default is False.
|
|
1138
|
+
|
|
1139
|
+
Returns:
|
|
1140
|
+
List[Model] | int: A list of Model objects or the count number.
|
|
1141
|
+
|
|
1142
|
+
Example:
|
|
1143
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1144
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1145
|
+
>>> models = await client.get_models(search="my_model",
|
|
1146
|
+
... search_fields="name, description",
|
|
1147
|
+
... order_by="name A",
|
|
1148
|
+
... return_count=True,
|
|
1149
|
+
... skip=0,
|
|
1150
|
+
... limit=10,
|
|
1151
|
+
... shared=False)
|
|
1152
|
+
"""
|
|
1153
|
+
return await Model.get_models(self, **kwargs)
|
|
1154
|
+
|
|
1155
|
+
|
|
1156
|
+
async def get_model(self, uuid: str, user_id: int = None) -> 'Model':
|
|
1157
|
+
"""
|
|
1158
|
+
[async] Get a model by its UUID.
|
|
1159
|
+
|
|
1160
|
+
Args:
|
|
1161
|
+
uuid (str): The UUID of the model to get.
|
|
1162
|
+
user_id (int, optional): Specific user. privileges required.
|
|
1163
|
+
|
|
1164
|
+
Returns:
|
|
1165
|
+
Model: The model object.
|
|
1166
|
+
|
|
1167
|
+
Raises:
|
|
1168
|
+
NotFoundError: If the model with the specified UUID is not found.
|
|
1169
|
+
|
|
1170
|
+
Example:
|
|
1171
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1172
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1173
|
+
>>> model = await client.get_model(uuid="12345678-1234-5678-1234-567812345678")
|
|
1174
|
+
"""
|
|
1175
|
+
return await Model.get_model(self, uuid, user_id)
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
async def get_model_by_name(self, name: str, user_id: int = None) -> Union['Model', None]:
|
|
1179
|
+
"""
|
|
1180
|
+
[async] Get a model by name
|
|
1181
|
+
|
|
1182
|
+
Args:
|
|
1183
|
+
name (str): the name of the model to get
|
|
1184
|
+
user_id (int, optional): specific user. privileges required.
|
|
1185
|
+
|
|
1186
|
+
Returns:
|
|
1187
|
+
Model | None: returns the model if a model matches the given name, else None
|
|
1188
|
+
|
|
1189
|
+
Example:
|
|
1190
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1191
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1192
|
+
>>> model = await client.get_model_by_name(name='test')
|
|
1193
|
+
"""
|
|
1194
|
+
return await Model.get_model_by_name(self, name, user_id)
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
async def get_maps(self, **kwargs) -> Union[List['Map'], int]:
|
|
1198
|
+
"""
|
|
1199
|
+
[async] Get list of maps with optional filtering and pagination.
|
|
1200
|
+
|
|
1201
|
+
Keyword Args:
|
|
1202
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
1203
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
1204
|
+
search_fields (str): comma separated list of fields for searching.
|
|
1205
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
1206
|
+
return_count (bool): Whether to return total count. default is False.
|
|
1207
|
+
skip (int): Number of items to skip. default is 0.
|
|
1208
|
+
limit (int): Number of items to return. default is 10.
|
|
1209
|
+
user_id (int): Specific user. privileges required.
|
|
1210
|
+
shared (bool): Whether to return shared maps. default is False.
|
|
1211
|
+
|
|
1212
|
+
Returns:
|
|
1213
|
+
List[Map] | int: A list of Map instances or the total number of maps.
|
|
1214
|
+
|
|
1215
|
+
Example:
|
|
1216
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1217
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1218
|
+
>>> maps = await client.get_maps(q="name LIKE '%My Map%'")
|
|
1219
|
+
"""
|
|
1220
|
+
return await Map.get_maps(self, **kwargs)
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
async def create_map(self,
|
|
1224
|
+
name: str,
|
|
1225
|
+
display_name: str = None,
|
|
1226
|
+
description: str = None,
|
|
1227
|
+
extent: List[float] = None,
|
|
1228
|
+
thumbnail: str = None,
|
|
1229
|
+
style: Dict = None,
|
|
1230
|
+
user_id: int = None) -> 'Map':
|
|
1231
|
+
"""
|
|
1232
|
+
[async] Create a new map.
|
|
1233
|
+
|
|
1234
|
+
Args:
|
|
1235
|
+
name (str): The name of the map.
|
|
1236
|
+
display_name (str, optional): The display name of the map.
|
|
1237
|
+
description (str, optional): The description of the map.
|
|
1238
|
+
extent (List[float], optional): The extent of the map.
|
|
1239
|
+
thumbnail (str, optional): The thumbnail of the map.
|
|
1240
|
+
style (Dict, optional): The style of the map.
|
|
1241
|
+
user_id (int, optional): Specific user. privileges required.
|
|
1242
|
+
|
|
1243
|
+
Returns:
|
|
1244
|
+
Map: The newly created map instance.
|
|
1245
|
+
|
|
1246
|
+
Raises:
|
|
1247
|
+
ValidationError: If the map data is invalid.
|
|
1248
|
+
|
|
1249
|
+
Example:
|
|
1250
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1251
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1252
|
+
>>> map = await client.create_map(name="my_map", display_name="My Map", description="This is a description of my map", extent=[10, 20, 30, 40], thumbnail="https://example.com/thumbnail.png", style={"type": "style"})
|
|
1253
|
+
"""
|
|
1254
|
+
return await Map.create_map(self, name, display_name, description, extent, thumbnail, style, user_id)
|
|
1255
|
+
|
|
1256
|
+
|
|
1257
|
+
async def get_map(self, uuid: str, user_id: int = None) -> 'Map':
|
|
1258
|
+
"""
|
|
1259
|
+
[async] Get a map by its UUID.
|
|
1260
|
+
|
|
1261
|
+
Args:
|
|
1262
|
+
uuid (str): The UUID of the map to get.
|
|
1263
|
+
user_id (int, optional): Specific user. privileges required.
|
|
1264
|
+
|
|
1265
|
+
Returns:
|
|
1266
|
+
Map: The map object.
|
|
1267
|
+
|
|
1268
|
+
Raises:
|
|
1269
|
+
NotFoundError: If the map with the specified UUID is not found.
|
|
1270
|
+
|
|
1271
|
+
Example:
|
|
1272
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1273
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1274
|
+
>>> map = await client.get_map(uuid="12345678-1234-5678-1234-567812345678")
|
|
1275
|
+
"""
|
|
1276
|
+
return await Map.get_map(self, uuid, user_id)
|
|
1277
|
+
|
|
1278
|
+
|
|
1279
|
+
async def get_map_by_name(self, name: str, user_id: int = None) -> Union['Map', None]:
|
|
1280
|
+
"""
|
|
1281
|
+
[async] Get a map by name
|
|
1282
|
+
|
|
1283
|
+
Args:
|
|
1284
|
+
name (str): the name of the map to get
|
|
1285
|
+
user_id (int, optional): specific user. privileges required.
|
|
1286
|
+
|
|
1287
|
+
Returns:
|
|
1288
|
+
Map | None: returns the map if a map matches the given name, else None
|
|
1289
|
+
|
|
1290
|
+
Example:
|
|
1291
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1292
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1293
|
+
>>> map = await client.get_map_by_name(name='test')
|
|
1294
|
+
"""
|
|
1295
|
+
return await Map.get_map_by_name(self, name, user_id)
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
async def get_queries(self, **kwargs) -> Union[List['Query'], int]:
|
|
1299
|
+
"""
|
|
1300
|
+
[async] Get Queries
|
|
1301
|
+
|
|
1302
|
+
Keyword Args:
|
|
1303
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
1304
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
1305
|
+
search_fields (str): comma separated list of fields for searching
|
|
1306
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
1307
|
+
return_count (bool): Whether to return total count. default is False.
|
|
1308
|
+
skip (int): Number of queries to skip. default is 0.
|
|
1309
|
+
limit(int): Maximum number of queries to return. default is 10.
|
|
1310
|
+
user_id (int): Specific user. privileges required.
|
|
1311
|
+
shared (bool): Whether to return shared queries. default is False.
|
|
1312
|
+
|
|
1313
|
+
Returns:
|
|
1314
|
+
List[Query] | int: list of queries or the number of queries.
|
|
1315
|
+
|
|
1316
|
+
Example:
|
|
1317
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1318
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1319
|
+
>>> queries = await client.get_queries()
|
|
1320
|
+
"""
|
|
1321
|
+
return await Query.get_queries(self, **kwargs)
|
|
1322
|
+
|
|
1323
|
+
|
|
1324
|
+
async def create_query(self, name: str, display_name: str = None, description: str = None, sql: str = None, params: List = None) -> 'Query':
|
|
1325
|
+
"""
|
|
1326
|
+
[async] Creates a new query.
|
|
1327
|
+
|
|
1328
|
+
Args:
|
|
1329
|
+
name (str): The name of the query.
|
|
1330
|
+
display_name (str, optional): The display name of the query.
|
|
1331
|
+
description (str, optional): The description of the query.
|
|
1332
|
+
sql (str, optional): The SQL statement for the query.
|
|
1333
|
+
params (list, optional): The parameters for the SQL statement.
|
|
1334
|
+
|
|
1335
|
+
Returns:
|
|
1336
|
+
Query: The created query instance.
|
|
1337
|
+
|
|
1338
|
+
Example:
|
|
1339
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1340
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1341
|
+
>>> query = await client.create_query(name='query_name', display_name='Query Name', sql='SELECT * FROM some_layer')
|
|
1342
|
+
"""
|
|
1343
|
+
return await Query.create_query(self, name, display_name, description, sql, params)
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
async def get_query(self, uuid: str, user_id: int = None) -> 'Query':
|
|
1347
|
+
"""
|
|
1348
|
+
[async] Retrieves a query by its UUID.
|
|
1349
|
+
|
|
1350
|
+
Args:
|
|
1351
|
+
uuid (str): The UUID of the query.
|
|
1352
|
+
user_id (int, optional): specific user ID. privileges required.
|
|
1353
|
+
|
|
1354
|
+
Returns:
|
|
1355
|
+
Query: The retrieved query instance.
|
|
1356
|
+
|
|
1357
|
+
Example:
|
|
1358
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1359
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1360
|
+
>>> query = await client.get_query(uuid="12345678-1234-5678-1234-567812345678")
|
|
1361
|
+
"""
|
|
1362
|
+
return await Query.get_query(self, uuid, user_id)
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
async def get_query_by_name(self, name: str, user_id: int = None) -> Union['Query', None]:
|
|
1366
|
+
"""
|
|
1367
|
+
[async] Get a query by name
|
|
1368
|
+
|
|
1369
|
+
Args:
|
|
1370
|
+
name (str): the name of the query to get
|
|
1371
|
+
user_id (int, optional): specific user. privileges required.
|
|
1372
|
+
|
|
1373
|
+
Returns:
|
|
1374
|
+
Query | None: returns the query if a query matches the given name, else None
|
|
1375
|
+
|
|
1376
|
+
Example:
|
|
1377
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1378
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1379
|
+
>>> query = await client.get_query_by_name(name='test')
|
|
1380
|
+
"""
|
|
1381
|
+
return await Query.get_query_by_name(self, name, user_id)
|
|
1382
|
+
|
|
1383
|
+
|
|
1384
|
+
async def get_system_queries(self, **kwargs) -> List['Query']:
|
|
1385
|
+
"""
|
|
1386
|
+
[async] Returns the system queries as a list of Query objects.
|
|
1387
|
+
|
|
1388
|
+
Keyword Args:
|
|
1389
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'".
|
|
1390
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
1391
|
+
search_fields (str): comma separated list of fields for searching.
|
|
1392
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
1393
|
+
return_count (bool): whether to return the total count of queries. default is False.
|
|
1394
|
+
skip (int): number of queries to skip. minimum is 0. default is 0.
|
|
1395
|
+
limit (int): number of queries to return. minimum is 1. default is 100.
|
|
1396
|
+
user_id (int): specific user. privileges required.
|
|
1397
|
+
shared (bool): whether to return shared queries. default is False.
|
|
1398
|
+
|
|
1399
|
+
Returns:
|
|
1400
|
+
List[Query]: list of system queries.
|
|
1401
|
+
|
|
1402
|
+
Example:
|
|
1403
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1404
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1405
|
+
>>> queries = await client.get_system_queries()
|
|
1406
|
+
"""
|
|
1407
|
+
return await Query.get_system_queries(self, **kwargs)
|
|
1408
|
+
|
|
1409
|
+
|
|
1410
|
+
async def get_users(self, **kwrags) -> Union[List['User'], int]:
|
|
1411
|
+
"""
|
|
1412
|
+
[async] Retrieves a list of users (Permission Required)
|
|
1413
|
+
|
|
1414
|
+
Keyword Args:
|
|
1415
|
+
status (UserStatus): the status of the users filter.
|
|
1416
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
1417
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
1418
|
+
search_fields (str): comma separated list of fields for searching.
|
|
1419
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
1420
|
+
return_count (bool): Whether to return total count. default is False.
|
|
1421
|
+
skip (int): Number of items to skip. default is 0.
|
|
1422
|
+
limit (int): Number of items to return. default is 10.
|
|
1423
|
+
user_id (int): Specific user. privileges required.
|
|
1424
|
+
shared (bool): Whether to return shared maps. default is False.
|
|
1425
|
+
|
|
1426
|
+
Returns:
|
|
1427
|
+
List[User] | int: list of users or the count number.
|
|
1428
|
+
|
|
1429
|
+
Example:
|
|
1430
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1431
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1432
|
+
>>> users = await client.get_users()
|
|
1433
|
+
"""
|
|
1434
|
+
return await User.get_users(self, **kwrags)
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
async def create_user(self,
|
|
1438
|
+
username: str,
|
|
1439
|
+
email: str,
|
|
1440
|
+
password: str,
|
|
1441
|
+
role: 'UserRole',
|
|
1442
|
+
first_name: str,
|
|
1443
|
+
last_name: str,
|
|
1444
|
+
mobile: str,
|
|
1445
|
+
status: 'UserStatus') -> 'User':
|
|
1446
|
+
"""
|
|
1447
|
+
[async] Create a User (Permission Required)
|
|
1448
|
+
|
|
1449
|
+
Args:
|
|
1450
|
+
username (str): the username of the user.
|
|
1451
|
+
email (str): the email of the user.
|
|
1452
|
+
password (str): the password of the user.
|
|
1453
|
+
role (UserRole): the role of the user.
|
|
1454
|
+
first_name (str): the firstname of the user.
|
|
1455
|
+
last_name (str): the lastname of the user.
|
|
1456
|
+
mobile (str): the mobile number of the user. e.g. "+98 9120123456".
|
|
1457
|
+
status (UserStatus): the status of the user.
|
|
1458
|
+
|
|
1459
|
+
Returns:
|
|
1460
|
+
User: the user object.
|
|
1461
|
+
|
|
1462
|
+
Example:
|
|
1463
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1464
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1465
|
+
>>> user = await client.create_user(username="user1",
|
|
1466
|
+
... email="user1@example.com",
|
|
1467
|
+
... password="P@ssw0rd",
|
|
1468
|
+
... role=UserRole.ACCOUNT_ADMIN,
|
|
1469
|
+
... first_name="user 1",
|
|
1470
|
+
... last_name="user 1",
|
|
1471
|
+
... mobile="+98 9120123456",
|
|
1472
|
+
... status=UserStatus.ACTIVE)
|
|
1473
|
+
"""
|
|
1474
|
+
return await User.create_user(self, username, email, password, role, first_name, last_name, mobile, status)
|
|
1475
|
+
|
|
1476
|
+
|
|
1477
|
+
async def search_users(self, search: str = None, skip: int = 0, limit: int = 10) -> List['User']:
|
|
1478
|
+
"""
|
|
1479
|
+
[async] Get list of users based on the search term.
|
|
1480
|
+
|
|
1481
|
+
Args:
|
|
1482
|
+
search (str, optional): The Search Term.
|
|
1483
|
+
skip (int, optional): Number of items to skip. default is 0.
|
|
1484
|
+
limit (int, optional): Number of items to return. default is 10.
|
|
1485
|
+
|
|
1486
|
+
Returns:
|
|
1487
|
+
List[User]: A list of User instances.
|
|
1488
|
+
|
|
1489
|
+
Example:
|
|
1490
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1491
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1492
|
+
>>> users = await client.get_users(search="John")
|
|
1493
|
+
"""
|
|
1494
|
+
return await User.search_users(self, search, skip, limit)
|
|
1495
|
+
|
|
1496
|
+
|
|
1497
|
+
async def get_user(self, user_id: str = 'me') -> 'User':
|
|
1498
|
+
"""
|
|
1499
|
+
[async] Get a user by its id (Permission Required)
|
|
1500
|
+
|
|
1501
|
+
Args:
|
|
1502
|
+
user_id (int, optional): Specific user. don't specify a user_id to get the current user.
|
|
1503
|
+
|
|
1504
|
+
Returns:
|
|
1505
|
+
User: the user object.
|
|
1506
|
+
|
|
1507
|
+
Raises:
|
|
1508
|
+
NotFoundError: If the user with the specified id is not found.
|
|
1509
|
+
|
|
1510
|
+
Example:
|
|
1511
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1512
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1513
|
+
>>> user = await client.get_user(user_id=1)
|
|
1514
|
+
get the current user
|
|
1515
|
+
>>> user = await client.get_user()
|
|
1516
|
+
"""
|
|
1517
|
+
return await User.get_user(self, user_id)
|
|
1518
|
+
|
|
1519
|
+
|
|
1520
|
+
async def get_my_sessions(self) -> List['Session']:
|
|
1521
|
+
"""
|
|
1522
|
+
[async] Get a list of user available sessions (Permission Required)
|
|
1523
|
+
|
|
1524
|
+
Returns:
|
|
1525
|
+
List[Session]: list of user sessions.
|
|
1526
|
+
|
|
1527
|
+
Example:
|
|
1528
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1529
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1530
|
+
>>> await client.get_my_sessions()
|
|
1531
|
+
"""
|
|
1532
|
+
user = await self.get_user()
|
|
1533
|
+
return await user.get_sessions()
|
|
1534
|
+
|
|
1535
|
+
|
|
1536
|
+
async def get_workflows(self, **kwargs) -> Union[List['Workflow'], int]:
|
|
1537
|
+
"""
|
|
1538
|
+
[async] Get list of workflows with optional filtering and pagination.
|
|
1539
|
+
|
|
1540
|
+
Keyword Args:
|
|
1541
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
1542
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
1543
|
+
search_fields (str): comma separated list of fields for searching.
|
|
1544
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
1545
|
+
return_count (bool): Whether to return total count. default is False.
|
|
1546
|
+
skip (int): Number of items to skip. default is 0.
|
|
1547
|
+
limit (int): Number of items to return. default is 10.
|
|
1548
|
+
user_id (int): Specific user. privileges required.
|
|
1549
|
+
shared (bool): Whether to return shared workflows. default is False.
|
|
1550
|
+
|
|
1551
|
+
Returns:
|
|
1552
|
+
List[Workflow] | int: A list of workflow instances or the total number of workflows.
|
|
1553
|
+
|
|
1554
|
+
Example:
|
|
1555
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1556
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1557
|
+
>>> workflows = await client.get_workflows(q="name LIKE '%My workflow%'")
|
|
1558
|
+
"""
|
|
1559
|
+
return await Workflow.get_workflows(self, **kwargs)
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
async def create_workflow(self,
|
|
1563
|
+
name: str,
|
|
1564
|
+
display_name: str = None,
|
|
1565
|
+
description: str = None,
|
|
1566
|
+
settings: Dict = {},
|
|
1567
|
+
thumbnail: str = None,
|
|
1568
|
+
user_id: int = None) -> 'Workflow':
|
|
1569
|
+
"""
|
|
1570
|
+
[async] Create a new workflow.
|
|
1571
|
+
|
|
1572
|
+
Args:
|
|
1573
|
+
name (str): The name of the Workflow.
|
|
1574
|
+
display_name (str): The display name of the workflow.
|
|
1575
|
+
description (str): The description of the workflow.
|
|
1576
|
+
settings (Dict): The settings of the workflow.
|
|
1577
|
+
thumbnail (str): The thumbnail of the workflow.
|
|
1578
|
+
user_id (int): Specific user. privileges workflow.
|
|
1579
|
+
|
|
1580
|
+
Returns:
|
|
1581
|
+
Workflow: The newly created workflow instance.
|
|
1582
|
+
|
|
1583
|
+
Raises:
|
|
1584
|
+
ValidationError: If the workflow data is invalid.
|
|
1585
|
+
|
|
1586
|
+
Example:
|
|
1587
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1588
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1589
|
+
>>> workflow = await client.create_workflow(name="my_workflow")
|
|
1590
|
+
"""
|
|
1591
|
+
return await Workflow.create_workflow(self, name, display_name, description, settings, thumbnail, user_id)
|
|
1592
|
+
|
|
1593
|
+
|
|
1594
|
+
async def get_workflow(self, uuid: str, user_id: int = None) -> 'Workflow':
|
|
1595
|
+
"""
|
|
1596
|
+
[async] Get a workflow by its UUID.
|
|
1597
|
+
|
|
1598
|
+
Args:
|
|
1599
|
+
uuid (str): The UUID of the workflow to get.
|
|
1600
|
+
user_id (int): Specific user. privileges required.
|
|
1601
|
+
|
|
1602
|
+
Returns:
|
|
1603
|
+
Workflow: The workflow object.
|
|
1604
|
+
|
|
1605
|
+
Raises:
|
|
1606
|
+
NotFoundError: If the workflow with the specified UUID is not found.
|
|
1607
|
+
|
|
1608
|
+
Example:
|
|
1609
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1610
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1611
|
+
>>> workflow = await client.get_workflow(uuid="12345678-1234-5678-1234-567812345678")
|
|
1612
|
+
"""
|
|
1613
|
+
return await Workflow.get_workflow(self, uuid, user_id)
|
|
1614
|
+
|
|
1615
|
+
|
|
1616
|
+
async def get_workflow_by_name(self, name: str, user_id: int = None) -> Union['Workflow', None]:
|
|
1617
|
+
"""
|
|
1618
|
+
[async] Get a workflow by name
|
|
1619
|
+
|
|
1620
|
+
Args:
|
|
1621
|
+
name (str): the name of the workflow to get
|
|
1622
|
+
user_id (int, optional): specific user. privileges required.
|
|
1623
|
+
|
|
1624
|
+
Returns:
|
|
1625
|
+
Workflow | None: returns the workflow if a workflow matches the given name, else None
|
|
1626
|
+
|
|
1627
|
+
Example:
|
|
1628
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1629
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1630
|
+
>>> workflow = await client.get_workflow_by_name(name='test')
|
|
1631
|
+
"""
|
|
1632
|
+
return await Workflow.get_workflow_by_name(self, name, user_id)
|
|
1633
|
+
|
|
1634
|
+
|
|
1635
|
+
async def get_versions(self, **kwargs) -> Union[List['VectorLayerVersion'], int]:
|
|
1636
|
+
"""
|
|
1637
|
+
[async] Get list of versions with optional filtering and pagination.
|
|
1638
|
+
|
|
1639
|
+
Keyword Args:
|
|
1640
|
+
layer_id (str): the id of the vector layer.
|
|
1641
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
1642
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
1643
|
+
search_fields (str): comma separated list of fields for searching.
|
|
1644
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
1645
|
+
return_count (bool): Whether to return total count. default is False.
|
|
1646
|
+
skip (int): Number of items to skip. default is 0.
|
|
1647
|
+
limit (int): Number of items to return. default is 10.
|
|
1648
|
+
user_id (int): Specific user. privileges required.
|
|
1649
|
+
shared (bool): Whether to return shared versions. default is False.
|
|
1650
|
+
|
|
1651
|
+
Returns:
|
|
1652
|
+
List[VectorLayerVersion] | int: A list of vector layer version instances or the total number of versions.
|
|
1653
|
+
|
|
1654
|
+
Example:
|
|
1655
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1656
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1657
|
+
>>> versions = await client.get_versions(q="name LIKE '%My version%'")
|
|
1658
|
+
"""
|
|
1659
|
+
return await VectorLayerVersion.get_versions(self, **kwargs)
|
|
1660
|
+
|
|
1661
|
+
|
|
1662
|
+
async def get_version(self, uuid: str, user_id: int = None) -> 'VectorLayerVersion':
|
|
1663
|
+
"""
|
|
1664
|
+
[async] Get a version by its UUID.
|
|
1665
|
+
|
|
1666
|
+
Args:
|
|
1667
|
+
uuid (str): The UUID of the version to get.
|
|
1668
|
+
user_id (int, optional): Specific user. privileges required.
|
|
1669
|
+
|
|
1670
|
+
Returns:
|
|
1671
|
+
VectorLayerVersion: The vector layer version object.
|
|
1672
|
+
|
|
1673
|
+
Raises:
|
|
1674
|
+
NotFoundError: If the version with the specified UUID is not found.
|
|
1675
|
+
|
|
1676
|
+
Example:
|
|
1677
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1678
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1679
|
+
>>> version = await client.get_version(uuid="12345678-1234-5678-1234-567812345678")
|
|
1680
|
+
"""
|
|
1681
|
+
return await VectorLayerVersion.get_version(self, uuid, user_id)
|
|
1682
|
+
|
|
1683
|
+
|
|
1684
|
+
async def get_version_by_name(self, name: str, user_id: int = None) -> 'VectorLayerVersion':
|
|
1685
|
+
"""
|
|
1686
|
+
[async] Get a version by name
|
|
1687
|
+
|
|
1688
|
+
Args:
|
|
1689
|
+
name (str): the name of the version to get
|
|
1690
|
+
user_id (int, optional): specific user. privileges required.
|
|
1691
|
+
|
|
1692
|
+
Returns:
|
|
1693
|
+
VectorLayerVersion | None: returns the version if a version matches the given name, else None
|
|
1694
|
+
|
|
1695
|
+
Example:
|
|
1696
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1697
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1698
|
+
>>> version = await client.get_version_by_name(name='test')
|
|
1699
|
+
"""
|
|
1700
|
+
return await VectorLayerVersion.get_version_by_name(self, name, user_id)
|
|
1701
|
+
|
|
1702
|
+
|
|
1703
|
+
async def get_layouts(self, **kwargs) -> Union[List['Layout'], int]:
|
|
1704
|
+
"""
|
|
1705
|
+
[async] Get list of layouts with optional filtering and pagination.
|
|
1706
|
+
|
|
1707
|
+
Keyword Args:
|
|
1708
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
1709
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
1710
|
+
search_fields (str): comma separated list of fields for searching.
|
|
1711
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
1712
|
+
return_count (bool): Whether to return total count. default is False.
|
|
1713
|
+
skip (int): Number of items to skip. default is 0.
|
|
1714
|
+
limit (int): Number of items to return. default is 10.
|
|
1715
|
+
user_id (int): Specific user. privileges required.
|
|
1716
|
+
shared (bool): Whether to return shared layouts. default is False.
|
|
1717
|
+
|
|
1718
|
+
Returns:
|
|
1719
|
+
List[Layout] | int: A list of layout instances or the total number of layouts.
|
|
1720
|
+
|
|
1721
|
+
Example:
|
|
1722
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1723
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1724
|
+
>>> layouts = await client.get_layouts(q="name LIKE '%My layout%'")
|
|
1725
|
+
"""
|
|
1726
|
+
return await Layout.get_layouts(self, **kwargs)
|
|
1727
|
+
|
|
1728
|
+
|
|
1729
|
+
async def create_layout(self,
|
|
1730
|
+
name: str,
|
|
1731
|
+
display_name: str = None,
|
|
1732
|
+
description: str = None,
|
|
1733
|
+
settings: Dict = {},
|
|
1734
|
+
thumbnail: str = None,
|
|
1735
|
+
user_id: int = None) -> 'Layout':
|
|
1736
|
+
"""
|
|
1737
|
+
[async] Create a new layout.
|
|
1738
|
+
|
|
1739
|
+
Args:
|
|
1740
|
+
name (str): The name of the layout.
|
|
1741
|
+
display_name (str): The display name of the layout.
|
|
1742
|
+
description (str): The description of the layout.
|
|
1743
|
+
settings (Dict): The settings of the layout.
|
|
1744
|
+
thumbnail (str): The thumbnail of the layout.
|
|
1745
|
+
user_id (int): Specific user. privileges layout.
|
|
1746
|
+
|
|
1747
|
+
Returns:
|
|
1748
|
+
Layout: The newly created layout instance.
|
|
1749
|
+
|
|
1750
|
+
Raises:
|
|
1751
|
+
ValidationError: If the layout data is invalid.
|
|
1752
|
+
|
|
1753
|
+
Example:
|
|
1754
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1755
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1756
|
+
>>> layout = await client.create_layout(name="my_layout")
|
|
1757
|
+
"""
|
|
1758
|
+
return await Layout.create_layout(self, name, display_name, description, settings, thumbnail, user_id)
|
|
1759
|
+
|
|
1760
|
+
|
|
1761
|
+
async def get_layout(self, uuid: str, user_id: int = None) -> 'Layout':
|
|
1762
|
+
"""
|
|
1763
|
+
[async] Get a layout by its UUID.
|
|
1764
|
+
|
|
1765
|
+
Args:
|
|
1766
|
+
uuid (str): The UUID of the layout to get.
|
|
1767
|
+
user_id (int): Specific user. privileges required.
|
|
1768
|
+
|
|
1769
|
+
Returns:
|
|
1770
|
+
Layout: The layout object.
|
|
1771
|
+
|
|
1772
|
+
Raises:
|
|
1773
|
+
NotFoundError: If the layout with the specified UUID is not found.
|
|
1774
|
+
|
|
1775
|
+
Example:
|
|
1776
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1777
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1778
|
+
>>> layout = await client.get_layout(uuid="12345678-1234-5678-1234-567812345678")
|
|
1779
|
+
"""
|
|
1780
|
+
return await Layout.get_layout(self, uuid, user_id)
|
|
1781
|
+
|
|
1782
|
+
|
|
1783
|
+
async def get_layout_by_name(self, name: str, user_id: int = None) -> Union['Layout', None]:
|
|
1784
|
+
"""
|
|
1785
|
+
[async] Get a layout by name
|
|
1786
|
+
|
|
1787
|
+
Args:
|
|
1788
|
+
name (str): the name of the layout to get
|
|
1789
|
+
user_id (int, optional): specific user. privileges required.
|
|
1790
|
+
|
|
1791
|
+
Returns:
|
|
1792
|
+
Layout | None: returns the layout if a layout matches the given name, else None
|
|
1793
|
+
|
|
1794
|
+
Example:
|
|
1795
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1796
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1797
|
+
>>> layout = await client.get_layout_by_name(name='test')
|
|
1798
|
+
"""
|
|
1799
|
+
return await Layout.get_layout_by_name(self, name, user_id)
|
|
1800
|
+
|
|
1801
|
+
|
|
1802
|
+
async def get_3dtiles(self, **kwargs) -> Union[List['Tile3d'], int]:
|
|
1803
|
+
"""
|
|
1804
|
+
[async] Get list of 3D Tiles with optional filtering and pagination.
|
|
1805
|
+
|
|
1806
|
+
Keyword Args:
|
|
1807
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
1808
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
1809
|
+
search_fields (str): comma separated list of fields for searching.
|
|
1810
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
1811
|
+
return_count (bool): Whether to return total count. default is False.
|
|
1812
|
+
skip (int): Number of items to skip. default is 0.
|
|
1813
|
+
limit (int): Number of items to return. default is 10.
|
|
1814
|
+
user_id (int): Specific user. privileges required.
|
|
1815
|
+
shared (bool): Whether to return shared maps. default is False.
|
|
1816
|
+
|
|
1817
|
+
Returns:
|
|
1818
|
+
List[Tile3d] | int: A list of 3D Tile instances or the total number of 3D Tiles.
|
|
1819
|
+
|
|
1820
|
+
Example:
|
|
1821
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1822
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1823
|
+
>>> tiles = await client.get_3dtiles(q="name LIKE '%My tile%'")
|
|
1824
|
+
"""
|
|
1825
|
+
return await Tile3d.get_3dtiles(self, **kwargs)
|
|
1826
|
+
|
|
1827
|
+
|
|
1828
|
+
async def get_3dtile(self, uuid: str, user_id: int = None) -> 'Tile3d':
|
|
1829
|
+
"""
|
|
1830
|
+
[async] Get a 3D Tile by its UUID.
|
|
1831
|
+
|
|
1832
|
+
Args:
|
|
1833
|
+
uuid (str): The UUID of the map to 3D Tile.
|
|
1834
|
+
user_id (int): Specific user. privileges required.
|
|
1835
|
+
|
|
1836
|
+
Returns:
|
|
1837
|
+
Tile3d: The 3D Tile object.
|
|
1838
|
+
|
|
1839
|
+
Raises:
|
|
1840
|
+
NotFoundError: If the 3D Tile with the specified UUID is not found.
|
|
1841
|
+
|
|
1842
|
+
Example:
|
|
1843
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1844
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1845
|
+
>>> tile = await client.get_3dtile(uuid="12345678-1234-5678-1234-567812345678")
|
|
1846
|
+
"""
|
|
1847
|
+
return await Tile3d.get_3dtile(self, uuid, user_id)
|
|
1848
|
+
|
|
1849
|
+
|
|
1850
|
+
async def get_3dtile_by_name(self, name: str, user_id: int = None) -> Union['Tile3d', None]:
|
|
1851
|
+
"""
|
|
1852
|
+
[async] Get a 3dtile by name
|
|
1853
|
+
|
|
1854
|
+
Args:
|
|
1855
|
+
name (str): the name of the 3dtile to get
|
|
1856
|
+
user_id (int, optional): specific user. privileges required.
|
|
1857
|
+
|
|
1858
|
+
Returns:
|
|
1859
|
+
Tile3d | None: returns the 3dtile if a 3dtile matches the given name, else None
|
|
1860
|
+
|
|
1861
|
+
Example:
|
|
1862
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1863
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1864
|
+
>>> tile3d = await client.get_3dtile_by_name(name='test')
|
|
1865
|
+
"""
|
|
1866
|
+
return await Tile3d.get_3dtile_by_name(self, name, user_id)
|
|
1867
|
+
|
|
1868
|
+
|
|
1869
|
+
async def get_system_settings(self) -> 'SystemSettings':
|
|
1870
|
+
"""
|
|
1871
|
+
[async] Get System Settings object (Permission Required).
|
|
1872
|
+
|
|
1873
|
+
Returns:
|
|
1874
|
+
SystemSetting: the system settings object.
|
|
1875
|
+
|
|
1876
|
+
Example:
|
|
1877
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1878
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1879
|
+
>>> setting = await client.get_system_settings()
|
|
1880
|
+
"""
|
|
1881
|
+
return await SystemSettings.get_system_settings(self)
|
|
1882
|
+
|
|
1883
|
+
|
|
1884
|
+
async def get_scenes(self, **kwargs) -> Union[List['Scene'], int]:
|
|
1885
|
+
"""
|
|
1886
|
+
[async] Get list of scenes with optional filtering and pagination.
|
|
1887
|
+
|
|
1888
|
+
Keyword Args:
|
|
1889
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
1890
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
1891
|
+
search_fields (str): comma separated list of fields for searching.
|
|
1892
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
1893
|
+
return_count (bool): Whether to return total count. default is False.
|
|
1894
|
+
skip (int): Number of items to skip. default is 0.
|
|
1895
|
+
limit (int): Number of items to return. default is 10.
|
|
1896
|
+
user_id (int): Specific user. privileges required.
|
|
1897
|
+
shared (bool): Whether to return shared scenes. default is False.
|
|
1898
|
+
|
|
1899
|
+
Returns:
|
|
1900
|
+
List[Scene] | int: A list of scene instances or the total number of scenes.
|
|
1901
|
+
|
|
1902
|
+
Example:
|
|
1903
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1904
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1905
|
+
>>> scenes = await client.get_scenes(q="name LIKE '%My scene%'")
|
|
1906
|
+
"""
|
|
1907
|
+
return await Scene.get_scenes(self, **kwargs)
|
|
1908
|
+
|
|
1909
|
+
|
|
1910
|
+
async def create_scene(self,
|
|
1911
|
+
name: str,
|
|
1912
|
+
display_name: str = None,
|
|
1913
|
+
description: str = None,
|
|
1914
|
+
settings: Dict = {},
|
|
1915
|
+
thumbnail: str = None,
|
|
1916
|
+
user_id: int = None) -> 'Scene':
|
|
1917
|
+
"""
|
|
1918
|
+
[async] Create a new scene.
|
|
1919
|
+
|
|
1920
|
+
Args:
|
|
1921
|
+
name (str): The name of the scene.
|
|
1922
|
+
display_name (str, optional): The display name of the scene.
|
|
1923
|
+
description (str, optional): The description of the scene.
|
|
1924
|
+
settings (Dict,optional): The settings of the scene.
|
|
1925
|
+
thumbnail (str, optional): The thumbnail of the scene.
|
|
1926
|
+
user_id (int, optional): Specific user. privileges required.
|
|
1927
|
+
|
|
1928
|
+
Returns:
|
|
1929
|
+
Scene: The newly created scene instance.
|
|
1930
|
+
|
|
1931
|
+
Raises:
|
|
1932
|
+
ValidationError: If the scene data is invalid.
|
|
1933
|
+
|
|
1934
|
+
Example:
|
|
1935
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1936
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1937
|
+
>>> scene = await client.create_scene(name="my_scene")
|
|
1938
|
+
"""
|
|
1939
|
+
return await Scene.create_scene(self,
|
|
1940
|
+
name,
|
|
1941
|
+
display_name,
|
|
1942
|
+
description,
|
|
1943
|
+
settings,
|
|
1944
|
+
thumbnail,
|
|
1945
|
+
user_id)
|
|
1946
|
+
|
|
1947
|
+
|
|
1948
|
+
async def get_scene(self, uuid: str, user_id: int = None) -> 'Scene':
|
|
1949
|
+
"""
|
|
1950
|
+
[async] Get a scene by its UUID.
|
|
1951
|
+
|
|
1952
|
+
Args:
|
|
1953
|
+
uuid (str): The UUID of the scene to get.
|
|
1954
|
+
user_id (int, optional): Specific user. privileges required.
|
|
1955
|
+
|
|
1956
|
+
Returns:
|
|
1957
|
+
Scene: The scene object.
|
|
1958
|
+
|
|
1959
|
+
Raises:
|
|
1960
|
+
NotFoundError: If the scene with the specified UUID is not found.
|
|
1961
|
+
|
|
1962
|
+
Example:
|
|
1963
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1964
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1965
|
+
>>> scene = await client.get_scene(uuid="12345678-1234-5678-1234-567812345678")
|
|
1966
|
+
"""
|
|
1967
|
+
return await Scene.get_scene(self, uuid, user_id)
|
|
1968
|
+
|
|
1969
|
+
|
|
1970
|
+
async def get_scene_by_name(self, name: str, user_id: int = None) -> Union['Scene', None]:
|
|
1971
|
+
"""
|
|
1972
|
+
[async] Get a scene by name
|
|
1973
|
+
|
|
1974
|
+
Args:
|
|
1975
|
+
name (str): the name of the scene to get
|
|
1976
|
+
user_id (int, optional): specific user. privileges required.
|
|
1977
|
+
|
|
1978
|
+
Returns:
|
|
1979
|
+
Scene | None: returns the scene if a scene matches the given name, else None
|
|
1980
|
+
|
|
1981
|
+
Example:
|
|
1982
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1983
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
1984
|
+
>>> scene = await client.get_scene_by_name(name='test')
|
|
1985
|
+
"""
|
|
1986
|
+
return await Scene.get_scene_by_name(self, name, user_id)
|
|
1987
|
+
|
|
1988
|
+
|
|
1989
|
+
async def route(self, stops: str, **kwargs) -> Dict:
|
|
1990
|
+
"""
|
|
1991
|
+
[async] Find best driving routes between coordinates and return results.
|
|
1992
|
+
|
|
1993
|
+
Args:
|
|
1994
|
+
stops (str): Comma-separated list of stop coordinates in the format lon,lat;lon,lat.
|
|
1995
|
+
|
|
1996
|
+
Keyword Args:
|
|
1997
|
+
alternatives (bool): Whether to return alternative routes. Default value : False.
|
|
1998
|
+
steps (bool): Whether to include step-by-step navigation instructions. Default value : False.
|
|
1999
|
+
geometries (RoutingGeometryType): Format of the returned geometry.
|
|
2000
|
+
overview (RoutingOverviewLevel): Level of detail in the returned geometry.
|
|
2001
|
+
annotations (bool): Whether to include additional metadata like speed, weight, etc.
|
|
2002
|
+
|
|
2003
|
+
Returns:
|
|
2004
|
+
Dict: the routing output
|
|
2005
|
+
|
|
2006
|
+
Example:
|
|
2007
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2008
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2009
|
+
>>> route = await client.route(stops="53,33;56,36",
|
|
2010
|
+
... alternatives=True,
|
|
2011
|
+
... steps=True,
|
|
2012
|
+
... geometries=RoutingGeometryType.geojson,
|
|
2013
|
+
... overview=RoutingOverviewLevel.full,
|
|
2014
|
+
... annotations=True)
|
|
2015
|
+
"""
|
|
2016
|
+
return await Routing.route(self, stops, **kwargs)
|
|
2017
|
+
|
|
2018
|
+
|
|
2019
|
+
async def get_plans(self, **kwargs) -> Union[List['Plan'], int]:
|
|
2020
|
+
"""
|
|
2021
|
+
[async] Get list of plans with optional filtering and pagination.
|
|
2022
|
+
|
|
2023
|
+
Keyword Args:
|
|
2024
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
2025
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
2026
|
+
search_fields (str): comma separated list of fields for searching.
|
|
2027
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
2028
|
+
return_count (bool): Whether to return total count. default is False.
|
|
2029
|
+
skip (int): Number of items to skip. default is 0.
|
|
2030
|
+
limit (int): Number of items to return. default is 10.
|
|
2031
|
+
user_id (int): Specific user. privileges required.
|
|
2032
|
+
shared (bool): Whether to return shared plans. default is False.
|
|
2033
|
+
|
|
2034
|
+
Returns:
|
|
2035
|
+
List[Plan] | int: A list of plan instances or the total number of plans.
|
|
2036
|
+
|
|
2037
|
+
Example:
|
|
2038
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2039
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2040
|
+
>>> plans = await client.get_plans(q="name LIKE '%My plan%'")
|
|
2041
|
+
"""
|
|
2042
|
+
return await Plan.get_plans(self, **kwargs)
|
|
2043
|
+
|
|
2044
|
+
|
|
2045
|
+
async def create_plan(self,
|
|
2046
|
+
name: str,
|
|
2047
|
+
plan_color: str,
|
|
2048
|
+
storage: int,
|
|
2049
|
+
concurrent_tasks: int,
|
|
2050
|
+
daily_api_calls: int,
|
|
2051
|
+
monthly_api_calls: int,
|
|
2052
|
+
daily_traffic: int,
|
|
2053
|
+
monthly_traffic: int,
|
|
2054
|
+
daily_process: int,
|
|
2055
|
+
monthly_process: int,
|
|
2056
|
+
number_of_days: int = None,
|
|
2057
|
+
display_name: str = None,
|
|
2058
|
+
description: str = None) -> 'Plan':
|
|
2059
|
+
"""
|
|
2060
|
+
[async] Create a new plan.
|
|
2061
|
+
|
|
2062
|
+
Args:
|
|
2063
|
+
name (str): The name of the plan.
|
|
2064
|
+
plan_color (str): hex value of the color. e.g. #000000.
|
|
2065
|
+
storage (int): storage value in bytes. must be greater that 1.
|
|
2066
|
+
concurrent_tasks (int): number of concurrent tasks. must be greater that 1.
|
|
2067
|
+
daily_api_calls (int): number of daily api calls. must be greater that 1.
|
|
2068
|
+
monthly_api_calls (int): number of monthly api calls. must be greater that 1.
|
|
2069
|
+
daily_traffic (int): number of daily traffic. must be greater that 1.
|
|
2070
|
+
monthly_traffic (int): number of monthly traffic. must be greater that 1.
|
|
2071
|
+
daily_process (int): number of daily processes. must be greater that 1.
|
|
2072
|
+
monthly_process (int): number of monthly processes. must be greater that 1.
|
|
2073
|
+
number_of_days (int, optional): number of days. must be greater that 1.
|
|
2074
|
+
display_name (str, optional): display name of the plan.
|
|
2075
|
+
description (str, optional): description of the plan.
|
|
2076
|
+
|
|
2077
|
+
Returns:
|
|
2078
|
+
Plan: The newly created plan instance.
|
|
2079
|
+
|
|
2080
|
+
Raises:
|
|
2081
|
+
ValidationError: If the plan data is invalid.
|
|
2082
|
+
|
|
2083
|
+
Example:
|
|
2084
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2085
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2086
|
+
>>> plan = await client.create_plan(name="new_plan",
|
|
2087
|
+
... display_name=" New Plan",
|
|
2088
|
+
... description="new plan description",
|
|
2089
|
+
... plan_color="#000000",
|
|
2090
|
+
... storage=10,
|
|
2091
|
+
... concurrent_tasks=10,
|
|
2092
|
+
... daily_api_calls=10,
|
|
2093
|
+
... monthly_api_calls=10,
|
|
2094
|
+
... daily_traffic=10,
|
|
2095
|
+
... monthly_traffic=10,
|
|
2096
|
+
... daily_process=10,
|
|
2097
|
+
... monthly_process=10,
|
|
2098
|
+
... number_of_days=10)
|
|
2099
|
+
"""
|
|
2100
|
+
return await Plan.create_plan(self,
|
|
2101
|
+
name,
|
|
2102
|
+
plan_color,
|
|
2103
|
+
storage,
|
|
2104
|
+
concurrent_tasks,
|
|
2105
|
+
daily_api_calls,
|
|
2106
|
+
monthly_api_calls,
|
|
2107
|
+
daily_traffic,
|
|
2108
|
+
monthly_traffic,
|
|
2109
|
+
daily_process,
|
|
2110
|
+
monthly_process,
|
|
2111
|
+
number_of_days,
|
|
2112
|
+
display_name,
|
|
2113
|
+
description)
|
|
2114
|
+
|
|
2115
|
+
|
|
2116
|
+
async def get_plan(self, plan_id: int) -> 'Plan':
|
|
2117
|
+
"""
|
|
2118
|
+
[async] Get a plan by its id.
|
|
2119
|
+
|
|
2120
|
+
Args:
|
|
2121
|
+
plan_id (int): The id of the plan to get.
|
|
2122
|
+
|
|
2123
|
+
Returns:
|
|
2124
|
+
Plan: The plan object
|
|
2125
|
+
|
|
2126
|
+
Raises:
|
|
2127
|
+
NotFoundError: If the plan with the specified id is not found.
|
|
2128
|
+
|
|
2129
|
+
Example:
|
|
2130
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2131
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2132
|
+
>>> plan = await client.get_plan(plan_id=1)
|
|
2133
|
+
"""
|
|
2134
|
+
return await Plan.get_plan(self, plan_id)
|
|
2135
|
+
|
|
2136
|
+
|
|
2137
|
+
async def get_plan_by_name(self, name: str) -> Union['Plan', None]:
|
|
2138
|
+
"""
|
|
2139
|
+
[async] Get a plan by name
|
|
2140
|
+
|
|
2141
|
+
Args:
|
|
2142
|
+
api (GeoboxClient): The GeoboxClient instance for making requests.
|
|
2143
|
+
name (str): the name of the plan to get
|
|
2144
|
+
|
|
2145
|
+
Returns:
|
|
2146
|
+
Plan | None: returns the plan if a plan matches the given name, else None
|
|
2147
|
+
|
|
2148
|
+
Example:
|
|
2149
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2150
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2151
|
+
>>> plan = await client.get_plan_by_name(name='test')
|
|
2152
|
+
"""
|
|
2153
|
+
return await Plan.get_plan_by_name(self, name)
|
|
2154
|
+
|
|
2155
|
+
|
|
2156
|
+
async def get_dashboards(self, **kwargs) -> Union[List['Dashboard'], int]:
|
|
2157
|
+
"""
|
|
2158
|
+
[async] Get list of Dashboards
|
|
2159
|
+
|
|
2160
|
+
Keyword Args:
|
|
2161
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
2162
|
+
search (str): search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
|
|
2163
|
+
search_fields (str): comma separated list of fields for searching.
|
|
2164
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
2165
|
+
return_count (bool): Whether to return total count. default is False.
|
|
2166
|
+
skip (int): Number of items to skip. default is 0.
|
|
2167
|
+
limit (int): Number of items to return. default is 10.
|
|
2168
|
+
user_id (int): Specific user. privileges required.
|
|
2169
|
+
shared (bool): Whether to return shared Dashboards. default is False.
|
|
2170
|
+
|
|
2171
|
+
Returns:
|
|
2172
|
+
List[Dashboard] | int: A list of Dashboard instances or the total number of Dashboards.
|
|
2173
|
+
|
|
2174
|
+
Example:
|
|
2175
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2176
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2177
|
+
>>> dashboards = await client.get_dashboards()
|
|
2178
|
+
"""
|
|
2179
|
+
return await Dashboard.get_dashboards(self, **kwargs)
|
|
2180
|
+
|
|
2181
|
+
|
|
2182
|
+
async def create_dashboard(self,
|
|
2183
|
+
name: str,
|
|
2184
|
+
display_name: str = None,
|
|
2185
|
+
description: str = None,
|
|
2186
|
+
settings: Dict = {},
|
|
2187
|
+
thumbnail: str = None,
|
|
2188
|
+
user_id: int = None) -> 'Dashboard':
|
|
2189
|
+
"""
|
|
2190
|
+
[async] Create a new Dashboard.
|
|
2191
|
+
|
|
2192
|
+
Args:
|
|
2193
|
+
name (str): The name of the Dashboard.
|
|
2194
|
+
display_name (str, optional): The display name of the Dashboard.
|
|
2195
|
+
description (str, optional): The description of the Dashboard.
|
|
2196
|
+
settings (Dict, optional): The settings of the sceDashboarde.
|
|
2197
|
+
thumbnail (str, optional): The thumbnail of the Dashboard.
|
|
2198
|
+
user_id (int, optional): Specific user. privileges required.
|
|
2199
|
+
|
|
2200
|
+
Returns:
|
|
2201
|
+
Dashboard: The newly created Dashboard instance.
|
|
2202
|
+
|
|
2203
|
+
Raises:
|
|
2204
|
+
ValidationError: If the Dashboard data is invalid.
|
|
2205
|
+
|
|
2206
|
+
Example:
|
|
2207
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2208
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2209
|
+
>>> dashboard = await client.create_dashboard(name="my_dashboard")
|
|
2210
|
+
"""
|
|
2211
|
+
return await Dashboard.create_dashboard(self,
|
|
2212
|
+
name,
|
|
2213
|
+
display_name,
|
|
2214
|
+
description,
|
|
2215
|
+
settings,
|
|
2216
|
+
thumbnail,
|
|
2217
|
+
user_id)
|
|
2218
|
+
|
|
2219
|
+
|
|
2220
|
+
async def get_dashboard(self, uuid: str, user_id: int = None) -> 'Dashboard':
|
|
2221
|
+
"""
|
|
2222
|
+
[async] Get a Dashboard by its UUID.
|
|
2223
|
+
|
|
2224
|
+
Args:
|
|
2225
|
+
uuid (str): The UUID of the Dashboard to get.
|
|
2226
|
+
user_id (int, optional): Specific user. privileges required.
|
|
2227
|
+
|
|
2228
|
+
Returns:
|
|
2229
|
+
Dashboard: The dashboard object.
|
|
2230
|
+
|
|
2231
|
+
Raises:
|
|
2232
|
+
NotFoundError: If the Dashboard with the specified UUID is not found.
|
|
2233
|
+
|
|
2234
|
+
Example:
|
|
2235
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2236
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2237
|
+
>>> dashboard = await client.get_dashboard(uuid="12345678-1234-5678-1234-567812345678")
|
|
2238
|
+
"""
|
|
2239
|
+
return await Dashboard.get_dashboard(self, uuid, user_id)
|
|
2240
|
+
|
|
2241
|
+
|
|
2242
|
+
async def get_dashboard_by_name(self, name: str, user_id: int = None) -> Union['Dashboard', None]:
|
|
2243
|
+
"""
|
|
2244
|
+
[async] Get a dashboard by name
|
|
2245
|
+
|
|
2246
|
+
Args:
|
|
2247
|
+
name (str): the name of the dashboard to get
|
|
2248
|
+
user_id (int, optional): specific user. privileges required.
|
|
2249
|
+
|
|
2250
|
+
Returns:
|
|
2251
|
+
Dashboard | None: returns the dashboard if a dashboard matches the given name, else None
|
|
2252
|
+
|
|
2253
|
+
Example:
|
|
2254
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2255
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2256
|
+
>>> dashboard = await client.get_dashboard_by_name(name='test')
|
|
2257
|
+
"""
|
|
2258
|
+
return await Dashboard.get_dashboard_by_name(self, name, user_id)
|
|
2259
|
+
|
|
2260
|
+
|
|
2261
|
+
async def get_basemaps(self) -> List['Basemap']:
|
|
2262
|
+
"""
|
|
2263
|
+
[async] Get a list of basemaps
|
|
2264
|
+
|
|
2265
|
+
Returns:
|
|
2266
|
+
List[BaseMap]: list of basemaps.
|
|
2267
|
+
|
|
2268
|
+
Example:
|
|
2269
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2270
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2271
|
+
>>> basemaps = await client.get_basemaps()
|
|
2272
|
+
"""
|
|
2273
|
+
return await Basemap.get_basemaps(self)
|
|
2274
|
+
|
|
2275
|
+
|
|
2276
|
+
async def get_basemap(self, name: str) -> 'Basemap':
|
|
2277
|
+
"""
|
|
2278
|
+
[async] Get a basemap object
|
|
2279
|
+
|
|
2280
|
+
Args:
|
|
2281
|
+
name: the basemap name
|
|
2282
|
+
|
|
2283
|
+
Returns:
|
|
2284
|
+
Basemap: the basemap object
|
|
2285
|
+
|
|
2286
|
+
Raises:
|
|
2287
|
+
NotFoundError: if the base,ap with the specified name not found
|
|
2288
|
+
|
|
2289
|
+
Example:
|
|
2290
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2291
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2292
|
+
>>> basemap = await client.get_basemap(name='test')
|
|
2293
|
+
"""
|
|
2294
|
+
return await Basemap.get_basemap(self, name)
|
|
2295
|
+
|
|
2296
|
+
|
|
2297
|
+
async def proxy_basemap(self, url: str) -> None:
|
|
2298
|
+
"""
|
|
2299
|
+
[async] Proxy the basemap
|
|
2300
|
+
|
|
2301
|
+
Args:
|
|
2302
|
+
url (str): the proxy server url.
|
|
2303
|
+
|
|
2304
|
+
Returns:
|
|
2305
|
+
None
|
|
2306
|
+
|
|
2307
|
+
Example:
|
|
2308
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2309
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2310
|
+
>>> await client.proxy_basemap(url='proxy_server_url')
|
|
2311
|
+
"""
|
|
2312
|
+
return await Basemap.proxy_basemap(self, url)
|
|
2313
|
+
|
|
2314
|
+
|
|
2315
|
+
async def get_attachments(self, resource: Union['Map', 'VectorLayer', 'VectorLayerView'], **kwargs) -> List['Attachment']:
|
|
2316
|
+
"""
|
|
2317
|
+
[async] Get the resouces attachments
|
|
2318
|
+
|
|
2319
|
+
Args:
|
|
2320
|
+
resource (Map | VectorLayer | VectorLayerView): options are: Map, Vector, View objects
|
|
2321
|
+
|
|
2322
|
+
Keyword Args:
|
|
2323
|
+
element_id (str): the id of the element with attachment.
|
|
2324
|
+
search (str): search term for keyword-based searching among all textual fields.
|
|
2325
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
2326
|
+
skip (int): Number of items to skip. default is 0.
|
|
2327
|
+
limit (int): Number of items to return. default is 10.
|
|
2328
|
+
return_count (bool): Whether to return total count. default is False.
|
|
2329
|
+
|
|
2330
|
+
Returns:
|
|
2331
|
+
List[Attachment] | int: A list of attachments instances or the total number of attachments.
|
|
2332
|
+
|
|
2333
|
+
Raises:
|
|
2334
|
+
TypeError: if the resource type is not supported
|
|
2335
|
+
|
|
2336
|
+
Example:
|
|
2337
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2338
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2339
|
+
>>> maps = await client.get_maps()
|
|
2340
|
+
>>> map = maps[0]
|
|
2341
|
+
>>> attachments = await client.get_attachments(resource=map)
|
|
2342
|
+
"""
|
|
2343
|
+
return await Attachment.get_attachments(self, resource=resource, **kwargs)
|
|
2344
|
+
|
|
2345
|
+
|
|
2346
|
+
async def create_attachment(self,
|
|
2347
|
+
name: str,
|
|
2348
|
+
loc_x: int,
|
|
2349
|
+
loc_y: int,
|
|
2350
|
+
resource: Union['Map', 'VectorLayer', 'VectorLayerView'],
|
|
2351
|
+
file: 'File',
|
|
2352
|
+
feature: 'Feature' = None,
|
|
2353
|
+
display_name: str = None,
|
|
2354
|
+
description: str = None, ) -> 'Attachment':
|
|
2355
|
+
"""
|
|
2356
|
+
[async] Create a new Attachment.
|
|
2357
|
+
|
|
2358
|
+
Args:
|
|
2359
|
+
name (str): The name of the scene.
|
|
2360
|
+
loc_x (int): x parameter of the attachment location.
|
|
2361
|
+
loc_y (int): y parameter of the attachment location.
|
|
2362
|
+
resource (Map | VectorLayer | VectorLayerView): the resource object.
|
|
2363
|
+
file (File): the file object.
|
|
2364
|
+
feature (Feature, optional): the feature object.
|
|
2365
|
+
display_name (str, optional): The display name of the scene.
|
|
2366
|
+
description (str, optional): The description of the scene.
|
|
2367
|
+
|
|
2368
|
+
Returns:
|
|
2369
|
+
Attachment: The newly created Attachment instance.
|
|
2370
|
+
|
|
2371
|
+
Raises:
|
|
2372
|
+
ValidationError: If the Attachment data is invalid.
|
|
2373
|
+
|
|
2374
|
+
Example:
|
|
2375
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2376
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2377
|
+
>>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
2378
|
+
>>> feature = await layer.get_feature(feature_id=1)
|
|
2379
|
+
>>> file = await client.get_file(uuid="12345678-1234-5678-1234-567812345678")
|
|
2380
|
+
>>> attachment = await client.create_attachment(name="my_attachment",
|
|
2381
|
+
... loc_x=30,
|
|
2382
|
+
... loc_y=50,
|
|
2383
|
+
... resource=layer,
|
|
2384
|
+
... file=file,
|
|
2385
|
+
... feature=feature,
|
|
2386
|
+
... display_name="My Attachment",
|
|
2387
|
+
... description="Attachment Description")
|
|
2388
|
+
"""
|
|
2389
|
+
return await Attachment.create_attachment(self,
|
|
2390
|
+
name,
|
|
2391
|
+
loc_x,
|
|
2392
|
+
loc_y,
|
|
2393
|
+
resource,
|
|
2394
|
+
file,
|
|
2395
|
+
feature,
|
|
2396
|
+
display_name,
|
|
2397
|
+
description)
|
|
2398
|
+
|
|
2399
|
+
|
|
2400
|
+
async def update_attachment(self, attachment_id: int, **kwargs) -> Dict:
|
|
2401
|
+
"""
|
|
2402
|
+
[async] Update the attachment.
|
|
2403
|
+
|
|
2404
|
+
Args:
|
|
2405
|
+
attachment_id (int): the attachment id.
|
|
2406
|
+
|
|
2407
|
+
Keyword Args:
|
|
2408
|
+
name (str): The name of the attachment.
|
|
2409
|
+
display_name (str): The display name of the attachment.
|
|
2410
|
+
description (str): The description of the attachment.
|
|
2411
|
+
loc_x (int): x parameter of the attachment location.
|
|
2412
|
+
loc_y (int): y parameter of the attachment location.
|
|
2413
|
+
|
|
2414
|
+
Returns:
|
|
2415
|
+
Dict: The updated attachment data.
|
|
2416
|
+
|
|
2417
|
+
Raises:
|
|
2418
|
+
ValidationError: If the attachment data is invalid.
|
|
2419
|
+
|
|
2420
|
+
Example:
|
|
2421
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2422
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2423
|
+
>>> await client.update_attachment(attachment_id=1, display_name="New Display Name")
|
|
2424
|
+
"""
|
|
2425
|
+
return await Attachment.update_attachment(self, attachment_id, **kwargs)
|
|
2426
|
+
|
|
2427
|
+
|
|
2428
|
+
async def get_apikeys(self, **kwargs) -> List['ApiKey']:
|
|
2429
|
+
"""
|
|
2430
|
+
[async] Get a list of apikeys
|
|
2431
|
+
|
|
2432
|
+
Keyword Args:
|
|
2433
|
+
search (str): search term for keyword-based searching among all textual fields.
|
|
2434
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
2435
|
+
skip (int): Number of layers to skip. default is 0.
|
|
2436
|
+
limit (int): Maximum number of layers to return. default is 10.
|
|
2437
|
+
user_id (int): Specific user. privileges required.
|
|
2438
|
+
|
|
2439
|
+
Example:
|
|
2440
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2441
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2442
|
+
>>> apikeys = await client.get_apikeys()
|
|
2443
|
+
"""
|
|
2444
|
+
return await ApiKey.get_apikeys(self, **kwargs)
|
|
2445
|
+
|
|
2446
|
+
|
|
2447
|
+
async def create_apikey(self, name: str, user_id: int = None) -> 'ApiKey':
|
|
2448
|
+
"""
|
|
2449
|
+
[async] Create an ApiKey
|
|
2450
|
+
|
|
2451
|
+
Args:
|
|
2452
|
+
name (str): name of the key.
|
|
2453
|
+
user_id (int, optional): Specific user. privileges required.
|
|
2454
|
+
|
|
2455
|
+
Returns:
|
|
2456
|
+
ApiKey: the apikey object
|
|
2457
|
+
|
|
2458
|
+
Example:
|
|
2459
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2460
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2461
|
+
>>> apikey = await client.create_apikey(name='test')
|
|
2462
|
+
"""
|
|
2463
|
+
return await ApiKey.create_apikey(self, name, user_id)
|
|
2464
|
+
|
|
2465
|
+
|
|
2466
|
+
async def get_apikey(self, key_id: int) -> 'ApiKey':
|
|
2467
|
+
"""
|
|
2468
|
+
[async] Get an ApiKey
|
|
2469
|
+
|
|
2470
|
+
Args:
|
|
2471
|
+
key_id (str): the id of the apikey.
|
|
2472
|
+
|
|
2473
|
+
Returns:
|
|
2474
|
+
ApiKey: the ApiKey object
|
|
2475
|
+
|
|
2476
|
+
Example:
|
|
2477
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2478
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2479
|
+
>>> apikey = await client.get_apikey(key_id=1)
|
|
2480
|
+
"""
|
|
2481
|
+
return await ApiKey.get_apikey(self, key_id)
|
|
2482
|
+
|
|
2483
|
+
|
|
2484
|
+
async def get_apikey_by_name(self, name: str, user_id: int = None) -> 'ApiKey':
|
|
2485
|
+
"""
|
|
2486
|
+
[async] Get an ApiKey by name
|
|
2487
|
+
|
|
2488
|
+
Args:
|
|
2489
|
+
name (str): the name of the key to get
|
|
2490
|
+
user_id (int, optional): specific user. privileges required.
|
|
2491
|
+
|
|
2492
|
+
Returns:
|
|
2493
|
+
ApiKey | None: returns the key if a key matches the given name, else None
|
|
2494
|
+
|
|
2495
|
+
Example:
|
|
2496
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2497
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2498
|
+
>>> apikey = await client.get_apikey_by_name(name='test')
|
|
2499
|
+
"""
|
|
2500
|
+
return await ApiKey.get_apikey_by_name(self, name, user_id)
|
|
2501
|
+
|
|
2502
|
+
|
|
2503
|
+
async def get_logs(self, **kwargs) -> List['Log']:
|
|
2504
|
+
"""
|
|
2505
|
+
[async] Get a list of Logs
|
|
2506
|
+
|
|
2507
|
+
Keyword Args:
|
|
2508
|
+
search (str): search term for keyword-based searching among all textual fields
|
|
2509
|
+
order_by (str): comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: "A" denotes ascending order and "D" denotes descending order.
|
|
2510
|
+
skip (int): Number of items to skip. default is 0.
|
|
2511
|
+
limit (int): Number of items to return. default is 10.
|
|
2512
|
+
user_id (int): Specific user. Privileges required.
|
|
2513
|
+
from_date (datetime): datetime object in this format: "%Y-%m-%dT%H:%M:%S.%f".
|
|
2514
|
+
to_date (datetime): datetime object in this format: "%Y-%m-%dT%H:%M:%S.%f".
|
|
2515
|
+
user_identity (str): the user identity in this format: username - firstname lastname - email .
|
|
2516
|
+
activity_type (str): the user activity type.
|
|
2517
|
+
|
|
2518
|
+
Returns:
|
|
2519
|
+
List[Log]: a list of logs
|
|
2520
|
+
|
|
2521
|
+
Example:
|
|
2522
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2523
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2524
|
+
>>> logs = await client.get_logs()
|
|
2525
|
+
"""
|
|
2526
|
+
return await Log.get_logs(self, **kwargs)
|
|
2527
|
+
|
|
2528
|
+
|
|
2529
|
+
async def get_api_usage(self,
|
|
2530
|
+
resource: Union['User', 'ApiKey'],
|
|
2531
|
+
scale: 'UsageScale',
|
|
2532
|
+
param: 'UsageParam',
|
|
2533
|
+
from_date: 'datetime' = None,
|
|
2534
|
+
to_date: 'datetime' = None,
|
|
2535
|
+
days_before_now: int = None,
|
|
2536
|
+
limit: int = None) -> List:
|
|
2537
|
+
"""
|
|
2538
|
+
[async] Get the api usage of a user
|
|
2539
|
+
|
|
2540
|
+
Args:
|
|
2541
|
+
resource (User | ApiKey): User or ApiKey object.
|
|
2542
|
+
scale (UsageScale): the scale of the report.
|
|
2543
|
+
param (UsageParam): traffic or calls.
|
|
2544
|
+
from_date (datetime, optional): datetime object in this format: "%Y-%m-%dT%H:%M:%S".
|
|
2545
|
+
to_date (datetime, optional): datetime object in this format: "%Y-%m-%dT%H:%M:%S".
|
|
2546
|
+
days_before_now (int, optional): number of days befor now.
|
|
2547
|
+
limit (int, optional): Number of items to return. default is 10.
|
|
2548
|
+
|
|
2549
|
+
Raises:
|
|
2550
|
+
ValueError: one of days_before_now or from_date/to_date parameters must have value
|
|
2551
|
+
ValueError: resource must be a 'user' or 'apikey' object
|
|
2552
|
+
|
|
2553
|
+
Returns:
|
|
2554
|
+
List: usage report
|
|
2555
|
+
|
|
2556
|
+
Example:
|
|
2557
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2558
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2559
|
+
>>> user = await client.get_user() # gets current user
|
|
2560
|
+
>>> usage = await client.get_api_usage(resource=user,
|
|
2561
|
+
... scale=UsageScale.Day,
|
|
2562
|
+
... param=UsageParam.Calls,
|
|
2563
|
+
... days_before_now=5)
|
|
2564
|
+
"""
|
|
2565
|
+
return await Usage.get_api_usage(self,
|
|
2566
|
+
resource=resource,
|
|
2567
|
+
scale=scale,
|
|
2568
|
+
param=param,
|
|
2569
|
+
from_date=from_date,
|
|
2570
|
+
to_date=to_date,
|
|
2571
|
+
days_before_now=days_before_now,
|
|
2572
|
+
limit=limit)
|
|
2573
|
+
|
|
2574
|
+
|
|
2575
|
+
async def get_process_usage(self,
|
|
2576
|
+
user_id: int = None,
|
|
2577
|
+
from_date: datetime = None,
|
|
2578
|
+
to_date: datetime = None,
|
|
2579
|
+
days_before_now: int = None) -> float:
|
|
2580
|
+
"""
|
|
2581
|
+
[async] Get process usage of a user in seconds
|
|
2582
|
+
|
|
2583
|
+
Args:
|
|
2584
|
+
user_id (int, optional): the id of the user. leave blank to get the current user report.
|
|
2585
|
+
from_date (datetime, optional): datetime object in this format: "%Y-%m-%dT%H:%M:%S".
|
|
2586
|
+
to_date (datetime, optional): datetime object in this format: "%Y-%m-%dT%H:%M:%S".
|
|
2587
|
+
days_before_now (int, optional): number of days befor now.
|
|
2588
|
+
|
|
2589
|
+
Raises:
|
|
2590
|
+
ValueError: one of days_before_now or from_date/to_date parameters must have value
|
|
2591
|
+
|
|
2592
|
+
Returns:
|
|
2593
|
+
float: process usage of a user in seconds
|
|
2594
|
+
|
|
2595
|
+
Example:
|
|
2596
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2597
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2598
|
+
>>> process_usage = await client.get_process_usage(days_before_now=5)
|
|
2599
|
+
"""
|
|
2600
|
+
return await Usage.get_process_usage(self,
|
|
2601
|
+
user_id=user_id,
|
|
2602
|
+
from_date=from_date,
|
|
2603
|
+
to_date=to_date,
|
|
2604
|
+
days_before_now=days_before_now)
|
|
2605
|
+
|
|
2606
|
+
|
|
2607
|
+
async def get_usage_summary(self, user_id: int = None) -> Dict:
|
|
2608
|
+
"""
|
|
2609
|
+
[async] Get the usage summary of a user
|
|
2610
|
+
|
|
2611
|
+
Args:
|
|
2612
|
+
user_id (int, optional): the id of the user. leave blank to get the current user report.
|
|
2613
|
+
|
|
2614
|
+
Returns:
|
|
2615
|
+
Dict: the usage summery of the users
|
|
2616
|
+
|
|
2617
|
+
Returns:
|
|
2618
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2619
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2620
|
+
>>> usage_summary = await client.get_usage_summary()
|
|
2621
|
+
"""
|
|
2622
|
+
return await Usage.get_usage_summary(self, user_id=user_id)
|
|
2623
|
+
|
|
2624
|
+
|
|
2625
|
+
async def update_usage(self, user_id: int = None) -> Dict:
|
|
2626
|
+
"""
|
|
2627
|
+
[async] Update usage of a user
|
|
2628
|
+
|
|
2629
|
+
Args:
|
|
2630
|
+
user_id (int, optional): the id of the user. leave blank to get the current user report.
|
|
2631
|
+
|
|
2632
|
+
Returns:
|
|
2633
|
+
Dict: the updated data
|
|
2634
|
+
|
|
2635
|
+
Example:
|
|
2636
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
2637
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
2638
|
+
>>> await client.update_usage()
|
|
2639
|
+
"""
|
|
2640
|
+
return await Usage.update_usage(self, user_id=user_id)
|