geobox 1.4.2__py3-none-any.whl → 2.0.1__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.
Files changed (66) hide show
  1. geobox/__init__.py +2 -2
  2. geobox/aio/__init__.py +63 -0
  3. geobox/aio/api.py +2640 -0
  4. geobox/aio/apikey.py +263 -0
  5. geobox/aio/attachment.py +339 -0
  6. geobox/aio/base.py +262 -0
  7. geobox/aio/basemap.py +196 -0
  8. geobox/aio/dashboard.py +342 -0
  9. geobox/aio/feature.py +527 -0
  10. geobox/aio/field.py +321 -0
  11. geobox/aio/file.py +522 -0
  12. geobox/aio/layout.py +341 -0
  13. geobox/aio/log.py +145 -0
  14. geobox/aio/map.py +1034 -0
  15. geobox/aio/model3d.py +415 -0
  16. geobox/aio/mosaic.py +696 -0
  17. geobox/aio/plan.py +315 -0
  18. geobox/aio/query.py +693 -0
  19. geobox/aio/raster.py +869 -0
  20. geobox/aio/route.py +63 -0
  21. geobox/aio/scene.py +342 -0
  22. geobox/aio/settings.py +194 -0
  23. geobox/aio/task.py +402 -0
  24. geobox/aio/tile3d.py +339 -0
  25. geobox/aio/tileset.py +672 -0
  26. geobox/aio/usage.py +243 -0
  27. geobox/aio/user.py +507 -0
  28. geobox/aio/vectorlayer.py +1363 -0
  29. geobox/aio/version.py +273 -0
  30. geobox/aio/view.py +983 -0
  31. geobox/aio/workflow.py +341 -0
  32. geobox/api.py +14 -15
  33. geobox/apikey.py +28 -1
  34. geobox/attachment.py +27 -1
  35. geobox/base.py +4 -4
  36. geobox/basemap.py +30 -1
  37. geobox/dashboard.py +27 -0
  38. geobox/feature.py +33 -13
  39. geobox/field.py +33 -21
  40. geobox/file.py +40 -46
  41. geobox/layout.py +28 -1
  42. geobox/log.py +31 -7
  43. geobox/map.py +34 -2
  44. geobox/model3d.py +31 -37
  45. geobox/mosaic.py +28 -7
  46. geobox/plan.py +29 -3
  47. geobox/query.py +39 -14
  48. geobox/raster.py +26 -13
  49. geobox/scene.py +26 -0
  50. geobox/settings.py +30 -1
  51. geobox/task.py +28 -6
  52. geobox/tile3d.py +27 -1
  53. geobox/tileset.py +26 -5
  54. geobox/usage.py +32 -1
  55. geobox/user.py +62 -6
  56. geobox/utils.py +34 -0
  57. geobox/vectorlayer.py +40 -4
  58. geobox/version.py +25 -1
  59. geobox/view.py +37 -17
  60. geobox/workflow.py +27 -1
  61. {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/METADATA +4 -1
  62. geobox-2.0.1.dist-info/RECORD +68 -0
  63. geobox-1.4.2.dist-info/RECORD +0 -38
  64. {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/WHEEL +0 -0
  65. {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/licenses/LICENSE +0 -0
  66. {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/top_level.txt +0 -0
geobox/aio/workflow.py ADDED
@@ -0,0 +1,341 @@
1
+ from typing import List, Dict, Optional, TYPE_CHECKING, Union
2
+
3
+ from .base import AsyncBase
4
+
5
+ if TYPE_CHECKING:
6
+ from . import AsyncGeoboxClient
7
+ from .user import User
8
+ from ..api import GeoboxClient as SyncGeoboxClient
9
+ from ..workflow import Workflow as SyncWorkflow
10
+
11
+
12
+ class Workflow(AsyncBase):
13
+
14
+ BASE_ENDPOINT = 'workflows/'
15
+
16
+ def __init__(self,
17
+ api: 'AsyncGeoboxClient',
18
+ uuid: str,
19
+ data: Optional[Dict] = {}):
20
+ """
21
+ Initialize an async workflow instance.
22
+
23
+ Args:
24
+ api (GeoboxClient): The GeoboxClient instance for making requests.
25
+ uuid (str): The unique identifier for the workflow.
26
+ data (Dict): The data of the workflow.
27
+ """
28
+ super().__init__(api, uuid=uuid, data=data)
29
+
30
+
31
+ @classmethod
32
+ async def get_workflows(cls, api: 'AsyncGeoboxClient', **kwargs) -> Union[List['Workflow'], int]:
33
+ """
34
+ [async] Get list of workflows with optional filtering
35
+
36
+ Args:
37
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
38
+
39
+ Keyword Args:
40
+ q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
41
+ 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.
42
+ search_fields (str): comma separated list of fields for searching.
43
+ 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.
44
+ return_count (bool): Whether to return total count. default is False.
45
+ skip (int): Number of items to skip. default is 0.
46
+ limit (int): Number of items to return. default is 10.
47
+ user_id (int): Specific user. privileges required.
48
+ shared (bool): Whether to return shared workflows. default is False.
49
+
50
+ Returns:
51
+ List[Workflow] | int: A list of workflow instances or the total number of workflows.
52
+
53
+ Example:
54
+ >>> from geobox.aio import AsyncGeoboxClient
55
+ >>> from geobox.aio.workflow import Workflow
56
+ >>> async with AsyncGeoboxClient() as client:
57
+ >>> workflows = await Workflow.get_workflows(client, q="name LIKE '%My workflow%'")
58
+ or
59
+ >>> workflows = await client.get_workflows(q="name LIKE '%My workflow%'")
60
+ """
61
+ params = {
62
+ 'f': 'json',
63
+ 'q': kwargs.get('q'),
64
+ 'search': kwargs.get('search'),
65
+ 'search_fields': kwargs.get('search_fields'),
66
+ 'order_by': kwargs.get('order_by'),
67
+ 'return_count': kwargs.get('return_count', False),
68
+ 'skip': kwargs.get('skip', 0),
69
+ 'limit': kwargs.get('limit', 10),
70
+ 'user_id': kwargs.get('user_id'),
71
+ 'shared': kwargs.get('shared', False)
72
+ }
73
+ return await super()._get_list(api, cls.BASE_ENDPOINT, params, factory_func=lambda api, item: Workflow(api, item['uuid'], item))
74
+
75
+
76
+ @classmethod
77
+ async def create_workflow(cls,
78
+ api: 'AsyncGeoboxClient',
79
+ name: str,
80
+ display_name: str = None,
81
+ description: str = None,
82
+ settings: Dict = {},
83
+ thumbnail: str = None,
84
+ user_id: int = None) -> 'Workflow':
85
+ """
86
+ [async] Create a new workflow.
87
+
88
+ Args:
89
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
90
+ name (str): The name of the Workflow.
91
+ display_name (str): The display name of the workflow.
92
+ description (str): The description of the workflow.
93
+ settings (Dict): The settings of the workflow.
94
+ thumbnail (str): The thumbnail of the workflow.
95
+ user_id (int): Specific user. privileges required.
96
+
97
+ Returns:
98
+ Workflow: The newly created workflow instance.
99
+
100
+ Raises:
101
+ ValidationError: If the workflow data is invalid.
102
+
103
+ Example:
104
+ >>> from geobox.aio import AsyncGeoboxClient
105
+ >>> from geobox.aio.workflow import Workflow
106
+ >>> async with AsyncGeoboxClient() as client:
107
+ >>> workflow = await Workflow.create_workflow(client, name="my_workflow")
108
+ or
109
+ >>> workflow = await client.create_workflow(name="my_workflow")
110
+ """
111
+ data = {
112
+ "name": name,
113
+ "display_name": display_name,
114
+ "description": description,
115
+ "settings": settings,
116
+ "thumbnail": thumbnail,
117
+ "user_id": user_id,
118
+ }
119
+ return await super()._create(api, cls.BASE_ENDPOINT, data, factory_func=lambda api, item: Workflow(api, item['uuid'], item))
120
+
121
+
122
+ @classmethod
123
+ async def get_workflow(cls, api: 'AsyncGeoboxClient', uuid: str, user_id: int = None) -> 'Workflow':
124
+ """
125
+ [async] Get a workflow by its UUID.
126
+
127
+ Args:
128
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
129
+ uuid (str): The UUID of the workflow to get.
130
+ user_id (int): Specific user. privileges required.
131
+
132
+ Returns:
133
+ Workflow: The workflow object.
134
+
135
+ Raises:
136
+ NotFoundError: If the workflow with the specified UUID is not found.
137
+
138
+ Example:
139
+ >>> from geobox.aio import AsyncGeoboxClient
140
+ >>> from geobox.aio.workflow import Workflow
141
+ >>> async with AsyncGeoboxClient() as client:
142
+ >>> workflow = await Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
143
+ or
144
+ >>> workflow = await client.get_workflow(uuid="12345678-1234-5678-1234-567812345678")
145
+ """
146
+ params = {
147
+ 'f': 'json',
148
+ 'user_id': user_id,
149
+ }
150
+ return await super()._get_detail(api, cls.BASE_ENDPOINT, uuid, params, factory_func=lambda api, item: Workflow(api, item['uuid'], item))
151
+
152
+
153
+ @classmethod
154
+ async def get_workflow_by_name(cls, api: 'AsyncGeoboxClient', name: str, user_id: int = None) -> Union['Workflow', None]:
155
+ """
156
+ [async] Get a workflow by name
157
+
158
+ Args:
159
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
160
+ name (str): the name of the workflow to get
161
+ user_id (int, optional): specific user. privileges required.
162
+
163
+ Returns:
164
+ Workflow | None: returns the workflow if a workflow matches the given name, else None
165
+
166
+ Example:
167
+ >>> from geobox.aio import AsyncGeoboxClient
168
+ >>> from geobox.aio.workflow import Workflow
169
+ >>> async with AsyncGeoboxClient() as client:
170
+ >>> workflow = await Workflow.get_workflow_by_name(client, name='test')
171
+ or
172
+ >>> workflow = await client.get_workflow_by_name(name='test')
173
+ """
174
+ workflows = await cls.get_workflows(api, q=f"name = '{name}'", user_id=user_id)
175
+ if workflows and workflows[0].name == name:
176
+ return workflows[0]
177
+ else:
178
+ return None
179
+
180
+
181
+ async def update(self, **kwargs) -> Dict:
182
+ """
183
+ [async] Update the workflow.
184
+
185
+ Keyword Args:
186
+ name (str): The name of the workflow.
187
+ display_name (str): The display name of the workflow.
188
+ description (str): The description of the workflow.
189
+ settings (Dict): The settings of the workflow.
190
+ thumbnail (str): The thumbnail of the workflow.
191
+
192
+ Returns:
193
+ Dict: The updated workflow data.
194
+
195
+ Raises:
196
+ ValidationError: If the workflow data is invalid.
197
+
198
+ Example:
199
+ >>> from geobox.aio import AsyncGeoboxClient
200
+ >>> from geobox.aio.workflow import Workflow
201
+ >>> async with AsyncGeoboxClient() as client:
202
+ >>> workflow = await Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
203
+ >>> await workflow.update_workflow(display_name="New Display Name")
204
+ """
205
+ data = {
206
+ "name": kwargs.get('name'),
207
+ "display_name": kwargs.get('display_name'),
208
+ "description": kwargs.get('description'),
209
+ "settings": kwargs.get('settings'),
210
+ "thumbnail": kwargs.get('thumbnail')
211
+ }
212
+ return await super()._update(self.endpoint, data)
213
+
214
+
215
+ async def delete(self) -> None:
216
+ """
217
+ [async] Delete the Workflow.
218
+
219
+ Returns:
220
+ None
221
+
222
+ Example:
223
+ >>> from geobox.aio import AsyncGeoboxClient
224
+ >>> from geobox.aio.workflow import Workflow
225
+ >>> async with AsyncGeoboxClient() as client:
226
+ >>> workflow = await Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
227
+ >>> await workflow.delete()
228
+ """
229
+ await super().delete(self.endpoint)
230
+
231
+
232
+ @property
233
+ def thumbnail(self) -> str:
234
+ """
235
+ Get the thumbnail URL of the Workflow.
236
+
237
+ Returns:
238
+ str: The thumbnail of the Workflow.
239
+
240
+ Example:
241
+ >>> from geobox.aio import AsyncGeoboxClient
242
+ >>> from geobox.aio.workflow import Workflow
243
+ >>> async with AsyncGeoboxClient() as client:
244
+ >>> workflow = await Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
245
+ >>> workflow.thumbnail
246
+ 'https://example.com/thumbnail.png'
247
+ """
248
+ return super().thumbnail()
249
+
250
+
251
+ async def share(self, users: List['User']) -> None:
252
+ """
253
+ [async] Shares the workflow with specified users.
254
+
255
+ Args:
256
+ users (List[User]): The list of user objects to share the workflow with.
257
+
258
+ Returns:
259
+ None
260
+
261
+ Example:
262
+ >>> from geobox.aio import AsyncGeoboxClient
263
+ >>> from geobox.aio.workflow import Workflow
264
+ >>> async with AsyncGeoboxClient() as client:
265
+ >>> workflow = await Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
266
+ >>> users = await client.search_users(search='John')
267
+ >>> await workflow.share(users=users)
268
+ """
269
+ await super()._share(self.endpoint, users)
270
+
271
+
272
+ async def unshare(self, users: List['User']) -> None:
273
+ """
274
+ [async] Unshares the workflow with specified users.
275
+
276
+ Args:
277
+ users (List[User]): The list of user objects to unshare the workflow with.
278
+
279
+ Returns:
280
+ None
281
+
282
+ Example:
283
+ >>> from geobox.aio import AsyncGeoboxClient
284
+ >>> from geobox.aio.workflow import Workflow
285
+ >>> async with AsyncGeoboxClient() as client:
286
+ >>> workflow = await Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
287
+ >>> users = await client.search_users(search='John')
288
+ >>> await workflow.unshare(users=users)
289
+ """
290
+ await super()._unshare(self.endpoint, users)
291
+
292
+
293
+ async def get_shared_users(self, search: str = None, skip: int = 0, limit: int = 10) -> List['User']:
294
+ """
295
+ [async] Retrieves the list of users the workflow is shared with.
296
+
297
+ Args:
298
+ search (str, optional): The search query.
299
+ skip (int, optional): The number of users to skip.
300
+ limit (int, optional): The maximum number of users to retrieve.
301
+
302
+ Returns:
303
+ List[User]: The list of shared users.
304
+
305
+ Example:
306
+ >>> from geobox.aio import AsyncGeoboxClient
307
+ >>> from geobox.aio.workflow import Workflow
308
+ >>> async with AsyncGeoboxClient() as client:
309
+ >>> workflow = await Workflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678")
310
+ >>> await workflow.get_shared_users(search='John', skip=0, limit=10)
311
+ """
312
+ params = {
313
+ 'search': search,
314
+ 'skip': skip,
315
+ 'limit': limit
316
+ }
317
+ return await super()._get_shared_users(self.endpoint, params)
318
+
319
+
320
+ def to_sync(self, sync_client: 'SyncGeoboxClient') -> 'SyncWorkflow':
321
+ """
322
+ Switch to sync version of the workflow instance to have access to the sync methods
323
+
324
+ Args:
325
+ sync_client (SyncGeoboxClient): The sync version of the GeoboxClient instance for making requests.
326
+
327
+ Returns:
328
+ geobox.workflow.Workflow: the sync instance of the workflow.
329
+
330
+ Example:
331
+ >>> from geobox import Geoboxclient
332
+ >>> from geobox.aio import AsyncGeoboxClient
333
+ >>> from geobox.aio.workflow import Workflow
334
+ >>> client = GeoboxClient()
335
+ >>> async with AsyncGeoboxClient() as async_client:
336
+ >>> workflow = await Workflow.get_workflow(async_client, uuid="12345678-1234-5678-1234-567812345678")
337
+ >>> sync_workflow = workflow.to_sync(client)
338
+ """
339
+ from ..workflow import Workflow as SyncWorkflow
340
+
341
+ return SyncWorkflow(api=sync_client, uuid=self.uuid, data=self.data)
geobox/api.py CHANGED
@@ -712,14 +712,14 @@ class GeoboxClient:
712
712
  >>> from geobox import GeoboxClient
713
713
  >>> client = GeoboxClient()
714
714
  >>> views = client.get_views(layer_id=1,
715
- include_settings=True,
716
- search="test",
717
- search_fields="name",
718
- order_by="name A",
719
- return_count=False,
720
- skip=0,
721
- limit=10,
722
- shared=True)
715
+ ... include_settings=True,
716
+ ... search="test",
717
+ ... search_fields="name",
718
+ ... order_by="name A",
719
+ ... return_count=False,
720
+ ... skip=0,
721
+ ... limit=10,
722
+ ... shared=True)
723
723
  """
724
724
  return VectorLayerView.get_views(self, **kwargs)
725
725
 
@@ -744,7 +744,7 @@ class GeoboxClient:
744
744
  return VectorLayerView.get_views_by_ids(self, ids, user_id, include_settings)
745
745
 
746
746
 
747
- def get_view(self, uuid: str) -> 'VectorLayerView':
747
+ def get_view(self, uuid: str, user_id: int = None) -> 'VectorLayerView':
748
748
  """
749
749
  Get a specific vector layer view by its UUID.
750
750
 
@@ -760,7 +760,7 @@ class GeoboxClient:
760
760
  >>> client = GeoboxClient()
761
761
  >>> view = client.get_view(uuid="12345678-1234-5678-1234-567812345678")
762
762
  """
763
- return VectorLayerView.get_view(self, uuid)
763
+ return VectorLayerView.get_view(self, uuid, user_id)
764
764
 
765
765
 
766
766
  def get_view_by_name(self, name: str, user_id: int = None) -> Union['VectorLayerView', None]:
@@ -801,7 +801,6 @@ class GeoboxClient:
801
801
 
802
802
  Example:
803
803
  >>> from geobox import GeoboxClient
804
- >>> from geobox.tileset import Tileset
805
804
  >>> client = GeoboxClient()
806
805
  >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
807
806
  >>> view = client.get_view(uuid="12345678-1234-5678-1234-567812345678")
@@ -1304,13 +1303,14 @@ class GeoboxClient:
1304
1303
  return Query.get_queries(self, **kwargs)
1305
1304
 
1306
1305
 
1307
- def create_query(self, name: str, display_name: str = None, sql: str = None, params: List = None) -> 'Query':
1306
+ def create_query(self, name: str, display_name: str = None, description: str = None, sql: str = None, params: List = None) -> 'Query':
1308
1307
  """
1309
1308
  Creates a new query.
1310
1309
 
1311
1310
  Args:
1312
1311
  name (str): The name of the query.
1313
1312
  display_name (str, optional): The display name of the query.
1313
+ description (str, optional): The description of the query.
1314
1314
  sql (str, optional): The SQL statement for the query.
1315
1315
  params (list, optional): The parameters for the SQL statement.
1316
1316
 
@@ -1322,7 +1322,7 @@ class GeoboxClient:
1322
1322
  >>> client = GeoboxClient()
1323
1323
  >>> query = client.create_query(name='query_name', display_name='Query Name', sql='SELECT * FROM some_layer')
1324
1324
  """
1325
- return Query.create_query(self, name, display_name, sql, params)
1325
+ return Query.create_query(self, name, display_name, description, sql, params)
1326
1326
 
1327
1327
 
1328
1328
  def get_query(self, uuid: str, user_id: int = None) -> 'Query':
@@ -2019,7 +2019,7 @@ class GeoboxClient:
2019
2019
  Example:
2020
2020
  >>> from geobox import GeoboxClient
2021
2021
  >>> client = GeoboxClient()
2022
- >>> plans = client.get_plan(q="name LIKE '%My plan%'")
2022
+ >>> plans = client.get_plans(q="name LIKE '%My plan%'")
2023
2023
  """
2024
2024
  return Plan.get_plans(self, **kwargs)
2025
2025
 
@@ -2317,7 +2317,6 @@ class GeoboxClient:
2317
2317
 
2318
2318
  Example:
2319
2319
  >>> from geobox import GeoboxClient
2320
- >>> from geobox.attachment import Attachment
2321
2320
  >>> client = GeoboxClient()
2322
2321
  >>> map = client.get_maps()[0]
2323
2322
  >>> attachments = client.get_attachments(resource=map)
geobox/apikey.py CHANGED
@@ -6,6 +6,9 @@ from .utils import clean_data
6
6
 
7
7
  if TYPE_CHECKING:
8
8
  from . import GeoboxClient
9
+ from .aio import AsyncGeoboxClient
10
+ from .aio.apikey import ApiKey as AsyncApikey
11
+
9
12
 
10
13
  class ApiKey(Base):
11
14
 
@@ -233,4 +236,28 @@ class ApiKey(Base):
233
236
  """
234
237
  endpoint = f"{self.endpoint}/grant"
235
238
  self.api.post(endpoint)
236
- self.data['revoked'] = False
239
+ self.data['revoked'] = False
240
+
241
+
242
+ def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncApikey':
243
+ """
244
+ Switch to async version of the apikey instance to have access to the async methods
245
+
246
+ Args:
247
+ async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
248
+
249
+ Returns:
250
+ geobox.aio.apikey.Apikey: the async instance of the apikey.
251
+
252
+ Example:
253
+ >>> from geobox import Geoboxclient
254
+ >>> from geobox.aio import AsyncGeoboxClient
255
+ >>> from geobox.apikey import ApiKey
256
+ >>> client = GeoboxClient()
257
+ >>> apikey = ApiKey.get_apikey(client, key_id=1)
258
+ >>> async with AsyncGeoboxClient() as async_client:
259
+ >>> async_apikey = apikey.to_async(async_client)
260
+ """
261
+ from .aio.apikey import ApiKey as AsyncApiKey
262
+
263
+ return AsyncApiKey(api=async_client, key_id=self.key_id, data=self.data)
geobox/attachment.py CHANGED
@@ -11,6 +11,9 @@ from .file import File
11
11
  if TYPE_CHECKING:
12
12
  from . import GeoboxClient
13
13
  from .feature import Feature
14
+ from .aio import AsyncGeoboxClient
15
+ from .aio.attachment import Attachment as AsyncAtachment
16
+
14
17
 
15
18
  class Attachment(Base):
16
19
 
@@ -309,4 +312,27 @@ class Attachment(Base):
309
312
  'https://example.com/thumbnail.png'
310
313
  """
311
314
  return super().thumbnail(format='')
312
-
315
+
316
+
317
+ def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncAtachment':
318
+ """
319
+ Switch to async version of the attachment instance to have access to the async methods
320
+
321
+ Args:
322
+ async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
323
+
324
+ Returns:
325
+ geobox.aio.attachment.Atachment: the async instance of the attachment.
326
+
327
+ Example:
328
+ >>> from geobox import Geoboxclient
329
+ >>> from geobox.aio import AsyncGeoboxClient
330
+ >>> from geobox.attachment import Attachment
331
+ >>> client = GeoboxClient()
332
+ >>> attachment = Attachment.get_attachment(client, uuid="12345678-1234-5678-1234-567812345678")
333
+ >>> async with AsyncGeoboxClient() as async_client:
334
+ >>> async_attachment = attachment.to_async(async_client)
335
+ """
336
+ from .aio.attachment import Attachment as AsyncAttachment
337
+
338
+ return AsyncAttachment(api=async_client, attachment_id=self.attachment_id, data=self.data)
geobox/base.py CHANGED
@@ -18,7 +18,7 @@ class Base:
18
18
  Initialize the Base class.
19
19
 
20
20
  Args:
21
- api (GeoboxClient): The API client
21
+ api (GeoboxClient): The GeoboxClient client
22
22
  uuid (str, optional): The UUID of the resource
23
23
  data (dict, optional): The data of the resource
24
24
  """
@@ -129,7 +129,7 @@ class Base:
129
129
  Internal method to get a list of resources by their IDs.
130
130
 
131
131
  Args:
132
- api (GeoboxClient): The API client
132
+ api (GeoboxClient): The GeoboxClient client
133
133
  endpoint (str): The endpoint of the resource
134
134
  params (dict): Additional parameters for filtering and pagination
135
135
  factory_func (Callable): A function to create the resource object
@@ -150,7 +150,7 @@ class Base:
150
150
  Internal method to get a single resource by UUID.
151
151
 
152
152
  Args:
153
- api (GeoboxClient): The API client
153
+ api (GeoboxClient): The GeoboxClient client
154
154
  uuid (str): The UUID of the resource
155
155
  params (dict): Additional parameters for filtering and pagination
156
156
  factory_func (Callable): A function to create the resource object
@@ -170,7 +170,7 @@ class Base:
170
170
  Internal method to create a resource.
171
171
 
172
172
  Args:
173
- api (GeoboxClient): The API client
173
+ api (GeoboxClient): The GeoboxClient client
174
174
  data (dict): The data to create the resource with
175
175
  factory_func (Callable): A function to create the resource object
176
176
 
geobox/basemap.py CHANGED
@@ -7,6 +7,9 @@ from .utils import clean_data
7
7
 
8
8
  if TYPE_CHECKING:
9
9
  from . import GeoboxClient
10
+ from .aio import AsyncGeoboxClient
11
+ from .aio.basemap import Basemap as AsyncBasemap
12
+
10
13
 
11
14
  class Basemap(Base):
12
15
 
@@ -163,4 +166,30 @@ class Basemap(Base):
163
166
  })
164
167
  query_string = urlencode(param)
165
168
  endpoint = urljoin(cls.BASE_ENDPOINT, f"?{query_string}")
166
- api.get(endpoint)
169
+ api.get(endpoint)
170
+
171
+
172
+ def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncBasemap':
173
+ """
174
+ Switch to async version of the basemap instance to have access to the async methods
175
+
176
+ Args:
177
+ async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
178
+
179
+ Returns:
180
+ geobox.aio.basemap.Basemap: the async instance of the basemap.
181
+
182
+ Example:
183
+ >>> from geobox import Geoboxclient
184
+ >>> from geobox.aio import AsyncGeoboxClient
185
+ >>> from geobox.basemap import Basemap
186
+ >>> client = GeoboxClient()
187
+ >>> basemap = Basemap.get_basemap(client, name='test')
188
+ or
189
+ >>> basemap = client.get_basemap(name='test')
190
+ >>> async with AsyncGeoboxClient() as async_client:
191
+ >>> async_basemap = basemap.to_async(async_client)
192
+ """
193
+ from .aio.basemap import Basemap as AsyncBasemap
194
+
195
+ return AsyncBasemap(api=async_client, data=self.data)
geobox/dashboard.py CHANGED
@@ -6,6 +6,9 @@ from .base import Base
6
6
  if TYPE_CHECKING:
7
7
  from . import GeoboxClient
8
8
  from .user import User
9
+ from .aio import AsyncGeoboxClient
10
+ from .aio.dashboard import Dashboard as AsyncDashboard
11
+
9
12
 
10
13
  class Dashboard(Base):
11
14
 
@@ -313,3 +316,27 @@ class Dashboard(Base):
313
316
  'limit': limit
314
317
  }
315
318
  return super()._get_shared_users(self.endpoint, params)
319
+
320
+
321
+ def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncDashboard':
322
+ """
323
+ Switch to async version of the dashboard instance to have access to the async methods
324
+
325
+ Args:
326
+ async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
327
+
328
+ Returns:
329
+ geobox.aio.dashboard.Dashboard: the async instance of the dashboard.
330
+
331
+ Example:
332
+ >>> from geobox import Geoboxclient
333
+ >>> from geobox.aio import AsyncGeoboxClient
334
+ >>> from geobox.dashboard import Dashboard
335
+ >>> client = GeoboxClient()
336
+ >>> dashboard = Dashboard.get_dashboard(client, uuid="12345678-1234-5678-1234-567812345678")
337
+ >>> async with AsyncGeoboxClient() as async_client:
338
+ >>> async_dashboard = dashboard.to_async(async_client)
339
+ """
340
+ from .aio.dashboard import Dashboard as AsyncDashboard
341
+
342
+ return AsyncDashboard(api=async_client, uuid=self.uuid, data=self.data)