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