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.
- geobox/__init__.py +2 -2
- geobox/aio/__init__.py +63 -0
- geobox/aio/api.py +2640 -0
- geobox/aio/apikey.py +263 -0
- geobox/aio/attachment.py +339 -0
- geobox/aio/base.py +262 -0
- geobox/aio/basemap.py +196 -0
- geobox/aio/dashboard.py +342 -0
- geobox/aio/feature.py +527 -0
- geobox/aio/field.py +321 -0
- geobox/aio/file.py +522 -0
- geobox/aio/layout.py +341 -0
- geobox/aio/log.py +145 -0
- geobox/aio/map.py +1034 -0
- geobox/aio/model3d.py +415 -0
- geobox/aio/mosaic.py +696 -0
- geobox/aio/plan.py +315 -0
- geobox/aio/query.py +693 -0
- geobox/aio/raster.py +869 -0
- geobox/aio/route.py +63 -0
- geobox/aio/scene.py +342 -0
- geobox/aio/settings.py +194 -0
- geobox/aio/task.py +402 -0
- geobox/aio/tile3d.py +339 -0
- geobox/aio/tileset.py +672 -0
- geobox/aio/usage.py +243 -0
- geobox/aio/user.py +507 -0
- geobox/aio/vectorlayer.py +1363 -0
- geobox/aio/version.py +273 -0
- geobox/aio/view.py +983 -0
- geobox/aio/workflow.py +341 -0
- geobox/api.py +14 -15
- geobox/apikey.py +28 -1
- geobox/attachment.py +27 -1
- geobox/base.py +4 -4
- geobox/basemap.py +30 -1
- geobox/dashboard.py +27 -0
- geobox/feature.py +33 -13
- geobox/field.py +33 -21
- geobox/file.py +40 -46
- geobox/layout.py +28 -1
- geobox/log.py +31 -7
- geobox/map.py +34 -2
- geobox/model3d.py +31 -37
- geobox/mosaic.py +28 -7
- geobox/plan.py +29 -3
- geobox/query.py +39 -14
- geobox/raster.py +26 -13
- geobox/scene.py +26 -0
- geobox/settings.py +30 -1
- geobox/task.py +28 -6
- geobox/tile3d.py +27 -1
- geobox/tileset.py +26 -5
- geobox/usage.py +32 -1
- geobox/user.py +62 -6
- geobox/utils.py +34 -0
- geobox/vectorlayer.py +40 -4
- geobox/version.py +25 -1
- geobox/view.py +37 -17
- geobox/workflow.py +27 -1
- {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/METADATA +4 -1
- geobox-2.0.1.dist-info/RECORD +68 -0
- geobox-1.4.2.dist-info/RECORD +0 -38
- {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/WHEEL +0 -0
- {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/licenses/LICENSE +0 -0
- {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/top_level.txt +0 -0
geobox/aio/dashboard.py
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
from typing import List, Dict, Optional, TYPE_CHECKING, Union
|
|
2
|
+
from urllib.parse import urljoin
|
|
3
|
+
|
|
4
|
+
from .base import AsyncBase
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from . import AsyncGeoboxClient
|
|
8
|
+
from .user import User
|
|
9
|
+
from ..api import GeoboxClient as SyncGeoboxClient
|
|
10
|
+
from ..dashboard import Dashboard as SyncDashboard
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Dashboard(AsyncBase):
|
|
14
|
+
|
|
15
|
+
BASE_ENDPOINT = 'dashboards/'
|
|
16
|
+
|
|
17
|
+
def __init__(self,
|
|
18
|
+
api: 'AsyncGeoboxClient',
|
|
19
|
+
uuid: str,
|
|
20
|
+
data: Optional[Dict] = {}):
|
|
21
|
+
"""
|
|
22
|
+
Initialize a Dashboard instance.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
26
|
+
uuid (str): The unique identifier for the Dashboard.
|
|
27
|
+
data (Dict, optional): The data of the Dashboard.
|
|
28
|
+
"""
|
|
29
|
+
super().__init__(api, uuid=uuid, data=data)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@classmethod
|
|
33
|
+
async def get_dashboards(cls, api: 'AsyncGeoboxClient', **kwargs) -> Union[List['Dashboard'], int]:
|
|
34
|
+
"""
|
|
35
|
+
[async] Get list of Dashboards
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
39
|
+
|
|
40
|
+
Keyword Args:
|
|
41
|
+
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
42
|
+
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.
|
|
43
|
+
search_fields (str): comma separated list of fields for searching.
|
|
44
|
+
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.
|
|
45
|
+
return_count (bool): Whether to return total count. default is False.
|
|
46
|
+
skip (int): Number of items to skip. default is 0.
|
|
47
|
+
limit (int): Number of items to return. default is 10.
|
|
48
|
+
user_id (int): Specific user. privileges required.
|
|
49
|
+
shared (bool): Whether to return shared Dashboards. default is False.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
List[Dashboard] | int: A list of Dashboard instances or the total number of Dashboards.
|
|
53
|
+
|
|
54
|
+
Example:
|
|
55
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
56
|
+
>>> from geobox.aio.dashboard import Dashboard
|
|
57
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
58
|
+
>>> dashboards = await Dashboard.get_dashboards(client)
|
|
59
|
+
or
|
|
60
|
+
>>> dashboards = await client.get_dashboards()
|
|
61
|
+
"""
|
|
62
|
+
params = {
|
|
63
|
+
'f': 'json',
|
|
64
|
+
'q': kwargs.get('q'),
|
|
65
|
+
'search': kwargs.get('search'),
|
|
66
|
+
'search_fields': kwargs.get('search_fields'),
|
|
67
|
+
'order_by': kwargs.get('order_by'),
|
|
68
|
+
'return_count': kwargs.get('return_count', False),
|
|
69
|
+
'skip': kwargs.get('skip', 0),
|
|
70
|
+
'limit': kwargs.get('limit', 10),
|
|
71
|
+
'user_id': kwargs.get('user_id'),
|
|
72
|
+
'shared': kwargs.get('shared', False)
|
|
73
|
+
}
|
|
74
|
+
return await super()._get_list(api, cls.BASE_ENDPOINT, params, factory_func=lambda api, item: Dashboard(api, item['uuid'], item))
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
async def create_dashboard(cls,
|
|
79
|
+
api: 'AsyncGeoboxClient',
|
|
80
|
+
name: str,
|
|
81
|
+
display_name: str = None,
|
|
82
|
+
description: str = None,
|
|
83
|
+
settings: Dict = {},
|
|
84
|
+
thumbnail: str = None,
|
|
85
|
+
user_id: int = None) -> 'Dashboard':
|
|
86
|
+
"""
|
|
87
|
+
[async] Create a new Dashboard.
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
91
|
+
name (str): The name of the Dashboard.
|
|
92
|
+
display_name (str, optional): The display name of the Dashboard.
|
|
93
|
+
description (str, optional): The description of the Dashboard.
|
|
94
|
+
settings (Dict, optional): The settings of the sceDashboarde.
|
|
95
|
+
thumbnail (str, optional): The thumbnail of the Dashboard.
|
|
96
|
+
user_id (int, optional): Specific user. privileges required.
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
Dashboard: The newly created Dashboard instance.
|
|
100
|
+
|
|
101
|
+
Raises:
|
|
102
|
+
ValidationError: If the Dashboard data is invalid.
|
|
103
|
+
|
|
104
|
+
Example:
|
|
105
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
106
|
+
>>> from geobox.aio.dashboard import Dashboard
|
|
107
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
108
|
+
>>> dashboard = await Dashboard.create_dashboard(client, name="my_dashboard")
|
|
109
|
+
or
|
|
110
|
+
>>> dashboard = await client.create_dashboard(name="my_dashboard")
|
|
111
|
+
"""
|
|
112
|
+
data = {
|
|
113
|
+
"name": name,
|
|
114
|
+
"display_name": display_name,
|
|
115
|
+
"description": description,
|
|
116
|
+
"settings": settings,
|
|
117
|
+
"thumbnail": thumbnail,
|
|
118
|
+
"user_id": user_id,
|
|
119
|
+
}
|
|
120
|
+
return await super()._create(api, cls.BASE_ENDPOINT, data, factory_func=lambda api, item: Dashboard(api, item['uuid'], item))
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
@classmethod
|
|
124
|
+
async def get_dashboard(cls, api: 'AsyncGeoboxClient', uuid: str, user_id: int = None) -> 'Dashboard':
|
|
125
|
+
"""
|
|
126
|
+
[async] Get a Dashboard by its UUID.
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
130
|
+
uuid (str): The UUID of the Dashboard to get.
|
|
131
|
+
user_id (int, optional): Specific user. privileges required.
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
Dashboard: The dashboard object.
|
|
135
|
+
|
|
136
|
+
Raises:
|
|
137
|
+
NotFoundError: If the Dashboard with the specified UUID is not found.
|
|
138
|
+
|
|
139
|
+
Example:
|
|
140
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
141
|
+
>>> from geobox.aio.dashboard import Dashboard
|
|
142
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
143
|
+
>>> dashboard = await Dashboard.get_dashboard(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
144
|
+
or
|
|
145
|
+
>>> dashboard = await client.get_dashboard(uuid="12345678-1234-5678-1234-567812345678")
|
|
146
|
+
"""
|
|
147
|
+
params = {
|
|
148
|
+
'f': 'json',
|
|
149
|
+
'user_id': user_id,
|
|
150
|
+
}
|
|
151
|
+
return await super()._get_detail(api, cls.BASE_ENDPOINT, uuid, params, factory_func=lambda api, item: Dashboard(api, item['uuid'], item))
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
@classmethod
|
|
155
|
+
async def get_dashboard_by_name(cls, api: 'AsyncGeoboxClient', name: str, user_id: int = None) -> Union['Dashboard', None]:
|
|
156
|
+
"""
|
|
157
|
+
[async] Get a dashboard by name
|
|
158
|
+
|
|
159
|
+
Args:
|
|
160
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
161
|
+
name (str): the name of the dashboard to get
|
|
162
|
+
user_id (int, optional): specific user. privileges required.
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
Dashboard | None: returns the dashboard if a dashboard matches the given name, else None
|
|
166
|
+
|
|
167
|
+
Example:
|
|
168
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
169
|
+
>>> from geobox.aio.dashboard import Dashboard
|
|
170
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
171
|
+
>>> dashboard = await Dashboard.get_dashboard_by_name(client, name='test')
|
|
172
|
+
or
|
|
173
|
+
>>> dashboard = await client.get_dashboard_by_name(name='test')
|
|
174
|
+
"""
|
|
175
|
+
dashboards = await cls.get_dashboards(api, q=f"name = '{name}'", user_id=user_id)
|
|
176
|
+
if dashboards and dashboards[0].name == name:
|
|
177
|
+
return dashboards[0]
|
|
178
|
+
else:
|
|
179
|
+
return None
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
async def update(self, **kwargs) -> Dict:
|
|
183
|
+
"""
|
|
184
|
+
[async] Update the Dashboard
|
|
185
|
+
|
|
186
|
+
Keyword Args:
|
|
187
|
+
name (str): The name of the Dashboard.
|
|
188
|
+
display_name (str): The display name of the Dashboard.
|
|
189
|
+
description (str): The description of the Dashboard.
|
|
190
|
+
settings (Dict): The settings of the Dashboard.
|
|
191
|
+
thumbnail (str): The thumbnail of the Dashboard.
|
|
192
|
+
|
|
193
|
+
Returns:
|
|
194
|
+
Dict: The updated Dashboard data.
|
|
195
|
+
|
|
196
|
+
Raises:
|
|
197
|
+
ValidationError: If the Dashboard data is invalid.
|
|
198
|
+
|
|
199
|
+
Example:
|
|
200
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
201
|
+
>>> from geobox.aio.dashboard import Dashboard
|
|
202
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
203
|
+
>>> dashboard = await Dashboard.get_dashboard(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
204
|
+
>>> await dashboard.update(display_name="New Display Name")
|
|
205
|
+
"""
|
|
206
|
+
data = {
|
|
207
|
+
"name": kwargs.get('name'),
|
|
208
|
+
"display_name": kwargs.get('display_name'),
|
|
209
|
+
"description": kwargs.get('description'),
|
|
210
|
+
"settings": kwargs.get('settings'),
|
|
211
|
+
"thumbnail": kwargs.get('thumbnail')
|
|
212
|
+
}
|
|
213
|
+
return await super()._update(self.endpoint, data)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
async def delete(self) -> None:
|
|
217
|
+
"""
|
|
218
|
+
[async] Delete the dashboard.
|
|
219
|
+
|
|
220
|
+
Returns:
|
|
221
|
+
None
|
|
222
|
+
|
|
223
|
+
Example:
|
|
224
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
225
|
+
>>> from geobox.aio.dashboard import Dashboard
|
|
226
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
227
|
+
>>> dashboard = await Dashboard.get_dashboard(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
228
|
+
>>> await dashboard.delete()
|
|
229
|
+
"""
|
|
230
|
+
await super().delete(self.endpoint)
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
@property
|
|
234
|
+
def thumbnail(self) -> str:
|
|
235
|
+
"""
|
|
236
|
+
Get the thumbnail URL of the dashboard.
|
|
237
|
+
|
|
238
|
+
Returns:
|
|
239
|
+
str: The thumbnail of the dashboard.
|
|
240
|
+
|
|
241
|
+
Example:
|
|
242
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
243
|
+
>>> from geobox.aio.dashboard import Dashboard
|
|
244
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
245
|
+
>>> dashboard = await Dashboard.get_dashboard(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
246
|
+
>>> dashboard.thumbnail
|
|
247
|
+
'https://example.com/thumbnail.png'
|
|
248
|
+
"""
|
|
249
|
+
return super().thumbnail()
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
async def share(self, users: List['User']) -> None:
|
|
253
|
+
"""
|
|
254
|
+
[async] Shares the Dashboard with specified users.
|
|
255
|
+
|
|
256
|
+
Args:
|
|
257
|
+
users (List[User]): The list of user objects to share the Dashboard with.
|
|
258
|
+
|
|
259
|
+
Returns:
|
|
260
|
+
None
|
|
261
|
+
|
|
262
|
+
Example:
|
|
263
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
264
|
+
>>> from geobox.aio.dashboard import Dashboard
|
|
265
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
266
|
+
>>> dashboard = await Dashboard.get_dashboard(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
267
|
+
>>> users = await client.search_users(search='John')
|
|
268
|
+
>>> await dashboard.share(users=users)
|
|
269
|
+
"""
|
|
270
|
+
await super()._share(self.endpoint, users)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
async def unshare(self, users: List['User']) -> None:
|
|
274
|
+
"""
|
|
275
|
+
[async] Unshares the Dashboard with specified users.
|
|
276
|
+
|
|
277
|
+
Args:
|
|
278
|
+
users (List[User]): The list of user objects to unshare the Dashboard with.
|
|
279
|
+
|
|
280
|
+
Returns:
|
|
281
|
+
None
|
|
282
|
+
|
|
283
|
+
Example:
|
|
284
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
285
|
+
>>> from geobox.aio.dashboard import Dashboard
|
|
286
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
287
|
+
>>> dashboard = await Dashboard.get_dashboard(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
288
|
+
>>> users = await client.search_users(search='John')
|
|
289
|
+
>>> await dashboard.unshare(users=users)
|
|
290
|
+
"""
|
|
291
|
+
await super()._unshare(self.endpoint, users)
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
async def get_shared_users(self, search: str = None, skip: int = 0, limit: int = 10) -> List['User']:
|
|
295
|
+
"""
|
|
296
|
+
[async] Retrieves the list of users the dashboard is shared with.
|
|
297
|
+
|
|
298
|
+
Args:
|
|
299
|
+
search (str, optional): The search query.
|
|
300
|
+
skip (int, optional): The number of users to skip.
|
|
301
|
+
limit (int, optional): The maximum number of users to retrieve.
|
|
302
|
+
|
|
303
|
+
Returns:
|
|
304
|
+
List[User]: The list of shared users.
|
|
305
|
+
|
|
306
|
+
Example:
|
|
307
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
308
|
+
>>> from geobox.aio.dashboard import Dashboard
|
|
309
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
310
|
+
>>> dashboard = await Dashboard.get_dashboard(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
311
|
+
>>> await dashboard.get_shared_users(search='John', skip=0, limit=10)
|
|
312
|
+
"""
|
|
313
|
+
params = {
|
|
314
|
+
'search': search,
|
|
315
|
+
'skip': skip,
|
|
316
|
+
'limit': limit
|
|
317
|
+
}
|
|
318
|
+
return await super()._get_shared_users(self.endpoint, params)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
def to_sync(self, sync_client: 'SyncGeoboxClient') -> 'SyncDashboard':
|
|
322
|
+
"""
|
|
323
|
+
Switch to sync version of the dashboard instance to have access to the sync methods
|
|
324
|
+
|
|
325
|
+
Args:
|
|
326
|
+
sync_client (SyncGeoboxClient): The sync version of the GeoboxClient instance for making requests.
|
|
327
|
+
|
|
328
|
+
Returns:
|
|
329
|
+
geobox.dashboard.Dashboard: the sync instance of the dashboard.
|
|
330
|
+
|
|
331
|
+
Example:
|
|
332
|
+
>>> from geobox import Geoboxclient
|
|
333
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
334
|
+
>>> from geobox.aio.dashboard import Dashboard
|
|
335
|
+
>>> client = GeoboxClient()
|
|
336
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
337
|
+
>>> dashboard = await Dashboard.get_dashboard(async_client, uuid="12345678-1234-5678-1234-567812345678")
|
|
338
|
+
>>> sync_dashboard = dashboard.to_sync(client)
|
|
339
|
+
"""
|
|
340
|
+
from ..dashboard import Dashboard as SyncDashboard
|
|
341
|
+
|
|
342
|
+
return SyncDashboard(api=sync_client, uuid=self.uuid, data=self.data)
|