geobox 1.0.0__py3-none-any.whl

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