geobox 2.0.1__py3-none-any.whl → 2.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- geobox/__init__.py +61 -63
- geobox/aio/__init__.py +61 -63
- geobox/aio/api.py +489 -473
- geobox/aio/apikey.py +263 -263
- geobox/aio/attachment.py +341 -339
- geobox/aio/base.py +261 -262
- geobox/aio/basemap.py +196 -196
- geobox/aio/dashboard.py +340 -342
- geobox/aio/feature.py +23 -33
- geobox/aio/field.py +315 -321
- geobox/aio/file.py +72 -72
- geobox/aio/layout.py +340 -341
- geobox/aio/log.py +23 -23
- geobox/aio/map.py +1033 -1034
- geobox/aio/model3d.py +415 -415
- geobox/aio/mosaic.py +696 -696
- geobox/aio/plan.py +314 -314
- geobox/aio/query.py +693 -693
- geobox/aio/raster.py +907 -869
- geobox/aio/raster_analysis.py +740 -0
- geobox/aio/route.py +4 -4
- geobox/aio/scene.py +340 -342
- geobox/aio/settings.py +18 -18
- geobox/aio/task.py +404 -402
- geobox/aio/tile3d.py +337 -339
- geobox/aio/tileset.py +102 -103
- geobox/aio/usage.py +52 -51
- geobox/aio/user.py +506 -507
- geobox/aio/vector_tool.py +1968 -0
- geobox/aio/vectorlayer.py +315 -306
- geobox/aio/version.py +272 -273
- geobox/aio/view.py +1019 -983
- geobox/aio/workflow.py +340 -341
- geobox/api.py +18 -2
- geobox/apikey.py +262 -262
- geobox/attachment.py +336 -337
- geobox/base.py +384 -384
- geobox/basemap.py +194 -194
- geobox/dashboard.py +339 -341
- geobox/enums.py +432 -348
- geobox/feature.py +5 -5
- geobox/field.py +320 -320
- geobox/file.py +4 -4
- geobox/layout.py +339 -340
- geobox/log.py +4 -4
- geobox/map.py +1031 -1032
- geobox/model3d.py +410 -410
- geobox/mosaic.py +696 -696
- geobox/plan.py +313 -313
- geobox/query.py +691 -691
- geobox/raster.py +907 -863
- geobox/raster_analysis.py +737 -0
- geobox/scene.py +341 -342
- geobox/settings.py +194 -194
- geobox/task.py +399 -400
- geobox/tile3d.py +337 -338
- geobox/tileset.py +4 -4
- geobox/usage.py +3 -3
- geobox/user.py +503 -503
- geobox/vector_tool.py +1968 -0
- geobox/vectorlayer.py +5 -5
- geobox/version.py +272 -272
- geobox/view.py +981 -981
- geobox/workflow.py +338 -339
- {geobox-2.0.1.dist-info → geobox-2.2.0.dist-info}/METADATA +15 -1
- geobox-2.2.0.dist-info/RECORD +72 -0
- geobox-2.0.1.dist-info/RECORD +0 -68
- {geobox-2.0.1.dist-info → geobox-2.2.0.dist-info}/WHEEL +0 -0
- {geobox-2.0.1.dist-info → geobox-2.2.0.dist-info}/licenses/LICENSE +0 -0
- {geobox-2.0.1.dist-info → geobox-2.2.0.dist-info}/top_level.txt +0 -0
geobox/aio/layout.py
CHANGED
|
@@ -1,341 +1,340 @@
|
|
|
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
|
|
8
|
-
from ..api import GeoboxClient
|
|
9
|
-
from ..layout import Layout
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class
|
|
13
|
-
|
|
14
|
-
BASE_ENDPOINT = 'layouts/'
|
|
15
|
-
|
|
16
|
-
def __init__(self,
|
|
17
|
-
api: 'AsyncGeoboxClient',
|
|
18
|
-
uuid: str,
|
|
19
|
-
data: Optional[Dict] = {}):
|
|
20
|
-
"""
|
|
21
|
-
Initialize a layout instance.
|
|
22
|
-
|
|
23
|
-
Args:
|
|
24
|
-
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
25
|
-
uuid (str): The unique identifier for the layout.
|
|
26
|
-
data (Dict): The data of the layout.
|
|
27
|
-
"""
|
|
28
|
-
super().__init__(api, uuid=uuid, data=data)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
@classmethod
|
|
32
|
-
async def get_layouts(cls, api: 'AsyncGeoboxClient', **kwargs) -> Union[List['
|
|
33
|
-
"""
|
|
34
|
-
Get list of layouts with optional filtering and pagination.
|
|
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 layouts. default is False.
|
|
49
|
-
|
|
50
|
-
Returns:
|
|
51
|
-
List[
|
|
52
|
-
|
|
53
|
-
Example:
|
|
54
|
-
>>> from geobox.aio import AsyncGeoboxClient
|
|
55
|
-
>>> from geobox.aio.layout import
|
|
56
|
-
>>> async with AsyncGeoboxClient() as client:
|
|
57
|
-
>>> layouts = await
|
|
58
|
-
or
|
|
59
|
-
>>> layouts = await client.get_layout(q="name LIKE '%My layout%'")
|
|
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:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
@classmethod
|
|
77
|
-
async def create_layout(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) -> '
|
|
85
|
-
"""
|
|
86
|
-
Create a new layout.
|
|
87
|
-
|
|
88
|
-
Args:
|
|
89
|
-
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
90
|
-
name (str): The name of the Layout.
|
|
91
|
-
display_name (str): The display name of the layout.
|
|
92
|
-
description (str): The description of the layout.
|
|
93
|
-
settings (Dict): The settings of the layout.
|
|
94
|
-
thumbnail (str): The thumbnail of the layout.
|
|
95
|
-
user_id (int): Specific user. privileges layout.
|
|
96
|
-
|
|
97
|
-
Returns:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
Raises:
|
|
101
|
-
ValidationError: If the layout data is invalid.
|
|
102
|
-
|
|
103
|
-
Example:
|
|
104
|
-
>>> from geobox.aio import AsyncGeoboxClient
|
|
105
|
-
>>> from geobox.aio.layout import
|
|
106
|
-
>>> async with AsyncGeoboxClient() as client:
|
|
107
|
-
>>> layout = await
|
|
108
|
-
or
|
|
109
|
-
>>> layout = await client.create_layout(name="my_layout")
|
|
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:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
@classmethod
|
|
123
|
-
async def get_layout(cls, api: 'AsyncGeoboxClient', uuid: str, user_id: int = None) -> '
|
|
124
|
-
"""
|
|
125
|
-
Get a layout by its UUID.
|
|
126
|
-
|
|
127
|
-
Args:
|
|
128
|
-
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
129
|
-
uuid (str): The UUID of the layout to get.
|
|
130
|
-
user_id (int): Specific user. privileges required.
|
|
131
|
-
|
|
132
|
-
Returns:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
Raises:
|
|
136
|
-
NotFoundError: If the layout with the specified UUID is not found.
|
|
137
|
-
|
|
138
|
-
Example:
|
|
139
|
-
>>> from geobox.aio import AsyncGeoboxClient
|
|
140
|
-
>>> from geobox.aio.layout import
|
|
141
|
-
>>> async with AsyncGeoboxClient() as client:
|
|
142
|
-
>>> layout = await
|
|
143
|
-
or
|
|
144
|
-
>>> layout = await client.get_layout(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:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
@classmethod
|
|
154
|
-
async def get_layout_by_name(cls, api: 'AsyncGeoboxClient', name: str, user_id: int = None) -> Union['
|
|
155
|
-
"""
|
|
156
|
-
Get a layout by name
|
|
157
|
-
|
|
158
|
-
Args:
|
|
159
|
-
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
160
|
-
name (str): the name of the layout to get
|
|
161
|
-
user_id (int, optional): specific user. privileges required.
|
|
162
|
-
|
|
163
|
-
Returns:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
Example:
|
|
167
|
-
>>> from geobox.aio import AsyncGeoboxClient
|
|
168
|
-
>>> from geobox.aio.layout import
|
|
169
|
-
>>> async with AsyncGeoboxClient() as client:
|
|
170
|
-
>>> layout = await
|
|
171
|
-
or
|
|
172
|
-
>>> layout = await client.get_layout_by_name(name='test')
|
|
173
|
-
"""
|
|
174
|
-
layouts = await cls.get_layouts(api, q=f"name = '{name}'", user_id=user_id)
|
|
175
|
-
if layouts and layouts[0].name == name:
|
|
176
|
-
return layouts[0]
|
|
177
|
-
else:
|
|
178
|
-
return None
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
async def update(self, **kwargs) -> Dict:
|
|
182
|
-
"""
|
|
183
|
-
Update the layout.
|
|
184
|
-
|
|
185
|
-
Keyword Args:
|
|
186
|
-
name (str): The name of the layout.
|
|
187
|
-
display_name (str): The display name of the layout.
|
|
188
|
-
description (str): The description of the layout.
|
|
189
|
-
settings (Dict): The settings of the layout.
|
|
190
|
-
thumbnail (str): The thumbnail of the layout.
|
|
191
|
-
|
|
192
|
-
Returns:
|
|
193
|
-
Dict: The updated layout data.
|
|
194
|
-
|
|
195
|
-
Raises:
|
|
196
|
-
ValidationError: If the layout data is invalid.
|
|
197
|
-
|
|
198
|
-
Example:
|
|
199
|
-
>>> from geobox.aio import AsyncGeoboxClient
|
|
200
|
-
>>> from geobox.aio.layout import
|
|
201
|
-
>>> async with AsyncGeoboxClient() as client:
|
|
202
|
-
>>> layout = await
|
|
203
|
-
>>> await layout.update(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
|
-
Delete the Layout.
|
|
218
|
-
|
|
219
|
-
Returns:
|
|
220
|
-
None
|
|
221
|
-
|
|
222
|
-
Example:
|
|
223
|
-
>>> from geobox.aio import AsyncGeoboxClient
|
|
224
|
-
>>> from geobox.aio.layout import
|
|
225
|
-
>>> async with AsyncGeoboxClient() as client:
|
|
226
|
-
>>> layout = await
|
|
227
|
-
>>> await layout.delete()
|
|
228
|
-
"""
|
|
229
|
-
await super().
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
@property
|
|
233
|
-
def thumbnail(self) -> str:
|
|
234
|
-
"""
|
|
235
|
-
Get the thumbnail URL of the Layout.
|
|
236
|
-
|
|
237
|
-
Returns:
|
|
238
|
-
str: The thumbnail of the Layout.
|
|
239
|
-
|
|
240
|
-
Example:
|
|
241
|
-
>>> from geobox.aio import AsyncGeoboxClient
|
|
242
|
-
>>> from geobox.aio.layout import
|
|
243
|
-
>>> async with AsyncGeoboxClient() as client:
|
|
244
|
-
>>> layout = await
|
|
245
|
-
>>> layout.thumbnail
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
>>> from geobox.aio import
|
|
263
|
-
>>>
|
|
264
|
-
>>>
|
|
265
|
-
>>>
|
|
266
|
-
>>> await
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
>>> from geobox.aio import
|
|
284
|
-
>>>
|
|
285
|
-
>>>
|
|
286
|
-
>>>
|
|
287
|
-
>>>
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
>>> from geobox.aio import
|
|
307
|
-
>>>
|
|
308
|
-
>>>
|
|
309
|
-
>>>
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
'
|
|
314
|
-
'
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
>>> from geobox import
|
|
332
|
-
>>> from geobox.aio import
|
|
333
|
-
>>>
|
|
334
|
-
>>>
|
|
335
|
-
>>>
|
|
336
|
-
>>>
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
return SyncLayout(api=sync_client, uuid=self.uuid, data=self.data)
|
|
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 AsyncUser
|
|
8
|
+
from ..api import GeoboxClient
|
|
9
|
+
from ..layout import Layout
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AsyncLayout(AsyncBase):
|
|
13
|
+
|
|
14
|
+
BASE_ENDPOINT = 'layouts/'
|
|
15
|
+
|
|
16
|
+
def __init__(self,
|
|
17
|
+
api: 'AsyncGeoboxClient',
|
|
18
|
+
uuid: str,
|
|
19
|
+
data: Optional[Dict] = {}):
|
|
20
|
+
"""
|
|
21
|
+
Initialize a layout instance.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
25
|
+
uuid (str): The unique identifier for the layout.
|
|
26
|
+
data (Dict): The data of the layout.
|
|
27
|
+
"""
|
|
28
|
+
super().__init__(api, uuid=uuid, data=data)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@classmethod
|
|
32
|
+
async def get_layouts(cls, api: 'AsyncGeoboxClient', **kwargs) -> Union[List['AsyncLayout'], int]:
|
|
33
|
+
"""
|
|
34
|
+
Get list of layouts with optional filtering and pagination.
|
|
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 layouts. default is False.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
List[AsyncLayout] | int: A list of layout instances or the total number of layouts.
|
|
52
|
+
|
|
53
|
+
Example:
|
|
54
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
55
|
+
>>> from geobox.aio.layout import AsyncLayout
|
|
56
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
57
|
+
>>> layouts = await AsyncLayout.get_layout(client, q="name LIKE '%My layout%'")
|
|
58
|
+
or
|
|
59
|
+
>>> layouts = await client.get_layout(q="name LIKE '%My layout%'")
|
|
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: AsyncLayout(api, item['uuid'], item))
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@classmethod
|
|
77
|
+
async def create_layout(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) -> 'AsyncLayout':
|
|
85
|
+
"""
|
|
86
|
+
Create a new layout.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
90
|
+
name (str): The name of the Layout.
|
|
91
|
+
display_name (str): The display name of the layout.
|
|
92
|
+
description (str): The description of the layout.
|
|
93
|
+
settings (Dict): The settings of the layout.
|
|
94
|
+
thumbnail (str): The thumbnail of the layout.
|
|
95
|
+
user_id (int): Specific user. privileges layout.
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
AsyncLayout: The newly created layout instance.
|
|
99
|
+
|
|
100
|
+
Raises:
|
|
101
|
+
ValidationError: If the layout data is invalid.
|
|
102
|
+
|
|
103
|
+
Example:
|
|
104
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
105
|
+
>>> from geobox.aio.layout import AsyncLayout
|
|
106
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
107
|
+
>>> layout = await AsyncLayout.create_layout(client, name="my_layout")
|
|
108
|
+
or
|
|
109
|
+
>>> layout = await client.create_layout(name="my_layout")
|
|
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: AsyncLayout(api, item['uuid'], item))
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
@classmethod
|
|
123
|
+
async def get_layout(cls, api: 'AsyncGeoboxClient', uuid: str, user_id: int = None) -> 'AsyncLayout':
|
|
124
|
+
"""
|
|
125
|
+
Get a layout by its UUID.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
129
|
+
uuid (str): The UUID of the layout to get.
|
|
130
|
+
user_id (int): Specific user. privileges required.
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
AsyncLayout: The layout object.
|
|
134
|
+
|
|
135
|
+
Raises:
|
|
136
|
+
NotFoundError: If the layout with the specified UUID is not found.
|
|
137
|
+
|
|
138
|
+
Example:
|
|
139
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
140
|
+
>>> from geobox.aio.layout import AsyncLayout
|
|
141
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
142
|
+
>>> layout = await AsyncLayout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
143
|
+
or
|
|
144
|
+
>>> layout = await client.get_layout(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: AsyncLayout(api, item['uuid'], item))
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
@classmethod
|
|
154
|
+
async def get_layout_by_name(cls, api: 'AsyncGeoboxClient', name: str, user_id: int = None) -> Union['AsyncLayout', None]:
|
|
155
|
+
"""
|
|
156
|
+
Get a layout by name
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
160
|
+
name (str): the name of the layout to get
|
|
161
|
+
user_id (int, optional): specific user. privileges required.
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
AsyncLayout | None: returns the layout if a layout matches the given name, else None
|
|
165
|
+
|
|
166
|
+
Example:
|
|
167
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
168
|
+
>>> from geobox.aio.layout import AsyncLayout
|
|
169
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
170
|
+
>>> layout = await AsyncLayout.get_layout_by_name(client, name='test')
|
|
171
|
+
or
|
|
172
|
+
>>> layout = await client.get_layout_by_name(name='test')
|
|
173
|
+
"""
|
|
174
|
+
layouts = await cls.get_layouts(api, q=f"name = '{name}'", user_id=user_id)
|
|
175
|
+
if layouts and layouts[0].name == name:
|
|
176
|
+
return layouts[0]
|
|
177
|
+
else:
|
|
178
|
+
return None
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
async def update(self, **kwargs) -> Dict:
|
|
182
|
+
"""
|
|
183
|
+
Update the layout.
|
|
184
|
+
|
|
185
|
+
Keyword Args:
|
|
186
|
+
name (str): The name of the layout.
|
|
187
|
+
display_name (str): The display name of the layout.
|
|
188
|
+
description (str): The description of the layout.
|
|
189
|
+
settings (Dict): The settings of the layout.
|
|
190
|
+
thumbnail (str): The thumbnail of the layout.
|
|
191
|
+
|
|
192
|
+
Returns:
|
|
193
|
+
Dict: The updated layout data.
|
|
194
|
+
|
|
195
|
+
Raises:
|
|
196
|
+
ValidationError: If the layout data is invalid.
|
|
197
|
+
|
|
198
|
+
Example:
|
|
199
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
200
|
+
>>> from geobox.aio.layout import AsyncLayout
|
|
201
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
202
|
+
>>> layout = await AsyncLayout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
203
|
+
>>> await layout.update(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
|
+
Delete the Layout.
|
|
218
|
+
|
|
219
|
+
Returns:
|
|
220
|
+
None
|
|
221
|
+
|
|
222
|
+
Example:
|
|
223
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
224
|
+
>>> from geobox.aio.layout import AsyncLayout
|
|
225
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
226
|
+
>>> layout = await AsyncLayout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
227
|
+
>>> await layout.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 Layout.
|
|
236
|
+
|
|
237
|
+
Returns:
|
|
238
|
+
str: The thumbnail of the Layout.
|
|
239
|
+
|
|
240
|
+
Example:
|
|
241
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
242
|
+
>>> from geobox.aio.layout import AsyncLayout
|
|
243
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
244
|
+
>>> layout = await AsyncLayout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
245
|
+
>>> layout.thumbnail
|
|
246
|
+
"""
|
|
247
|
+
return super()._thumbnail()
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
async def share(self, users: List['AsyncUser']) -> None:
|
|
251
|
+
"""
|
|
252
|
+
Shares the layout with specified users.
|
|
253
|
+
|
|
254
|
+
Args:
|
|
255
|
+
users (List[AsyncUser]): The list of user objects to share the layout with.
|
|
256
|
+
|
|
257
|
+
Returns:
|
|
258
|
+
None
|
|
259
|
+
|
|
260
|
+
Example:
|
|
261
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
262
|
+
>>> from geobox.aio.layout import AsyncLayout
|
|
263
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
264
|
+
>>> layout = await AsyncLayout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
265
|
+
>>> await users = client.search_users(search='John')
|
|
266
|
+
>>> await layout.share(users=users)
|
|
267
|
+
"""
|
|
268
|
+
await super()._share(self.endpoint, users)
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
async def unshare(self, users: List['AsyncUser']) -> None:
|
|
272
|
+
"""
|
|
273
|
+
Unshares the layout with specified users.
|
|
274
|
+
|
|
275
|
+
Args:
|
|
276
|
+
users (List[AsyncUser]): The list of user objects to unshare the layout with.
|
|
277
|
+
|
|
278
|
+
Returns:
|
|
279
|
+
None
|
|
280
|
+
|
|
281
|
+
Example:
|
|
282
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
283
|
+
>>> from geobox.aio.layout import AsyncLayout
|
|
284
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
285
|
+
>>> layout = await AsyncLayout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
286
|
+
>>> users = await client.search_users(search='John')
|
|
287
|
+
>>> await layout.unshare(users=users)
|
|
288
|
+
"""
|
|
289
|
+
await super()._unshare(self.endpoint, users)
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
async def get_shared_users(self, search: str = None, skip: int = 0, limit: int = 10) -> List['AsyncUser']:
|
|
293
|
+
"""
|
|
294
|
+
Retrieves the list of users the layout is shared with.
|
|
295
|
+
|
|
296
|
+
Args:
|
|
297
|
+
search (str, optional): The search query.
|
|
298
|
+
skip (int, optional): The number of users to skip.
|
|
299
|
+
limit (int, optional): The maximum number of users to retrieve.
|
|
300
|
+
|
|
301
|
+
Returns:
|
|
302
|
+
List[User]: The list of shared users.
|
|
303
|
+
|
|
304
|
+
Example:
|
|
305
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
306
|
+
>>> from geobox.aio.layout import AsyncLayout
|
|
307
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
308
|
+
>>> layout = await AsyncLayout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
309
|
+
>>> await layout.get_shared_users(search='John', skip=0, limit=10)
|
|
310
|
+
"""
|
|
311
|
+
params = {
|
|
312
|
+
'search': search,
|
|
313
|
+
'skip': skip,
|
|
314
|
+
'limit': limit
|
|
315
|
+
}
|
|
316
|
+
return await super()._get_shared_users(self.endpoint, params)
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def to_sync(self, sync_client: 'GeoboxClient') -> 'Layout':
|
|
320
|
+
"""
|
|
321
|
+
Switch to sync version of the layout instance to have access to the sync methods
|
|
322
|
+
|
|
323
|
+
Args:
|
|
324
|
+
sync_client (GeoboxClient): The sync version of the GeoboxClient instance for making requests.
|
|
325
|
+
|
|
326
|
+
Returns:
|
|
327
|
+
Layout: the sync instance of the layout.
|
|
328
|
+
|
|
329
|
+
Example:
|
|
330
|
+
>>> from geobox import Geoboxclient
|
|
331
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
332
|
+
>>> from geobox.aio.layout import AsyncLayout
|
|
333
|
+
>>> client = GeoboxClient()
|
|
334
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
335
|
+
>>> layout = await AsyncLayout.get_layout(async_client, uuid="12345678-1234-5678-1234-567812345678")
|
|
336
|
+
>>> sync_layout = layout.to_sync(client)
|
|
337
|
+
"""
|
|
338
|
+
from ..layout import Layout
|
|
339
|
+
|
|
340
|
+
return Layout(api=sync_client, uuid=self.uuid, data=self.data)
|