geobox 1.4.1__py3-none-any.whl → 2.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/__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 +702 -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 -13
- 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 +56 -5
- geobox/model3d.py +98 -19
- geobox/mosaic.py +47 -7
- geobox/plan.py +29 -3
- geobox/query.py +41 -5
- geobox/raster.py +45 -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 +59 -4
- geobox/version.py +25 -1
- geobox/view.py +54 -15
- geobox/workflow.py +27 -1
- {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/METADATA +4 -1
- geobox-2.0.0.dist-info/RECORD +68 -0
- geobox-1.4.1.dist-info/RECORD +0 -38
- {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/WHEEL +0 -0
- {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/licenses/LICENSE +0 -0
- {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/top_level.txt +0 -0
geobox/aio/version.py
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
from typing import TYPE_CHECKING, Dict, List, Optional, Union
|
|
2
|
+
|
|
3
|
+
from .base import AsyncBase
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from .api import AsyncGeoboxClient
|
|
7
|
+
from .user import User
|
|
8
|
+
from ..api import GeoboxClient as SyncGeoboxClient
|
|
9
|
+
from ..version import VectorLayerVersion as SyncVectorLayerVersion
|
|
10
|
+
|
|
11
|
+
class VectorLayerVersion(AsyncBase):
|
|
12
|
+
|
|
13
|
+
BASE_ENDPOINT = 'vectorLayerVersions/'
|
|
14
|
+
|
|
15
|
+
def __init__(self,
|
|
16
|
+
api: 'AsyncGeoboxClient',
|
|
17
|
+
uuid: str,
|
|
18
|
+
data: Optional[Dict] = {}):
|
|
19
|
+
"""
|
|
20
|
+
Initialize a vector layer version instance.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
24
|
+
uuid (str): The unique identifier for the version.
|
|
25
|
+
data (Dict): The data of the version.
|
|
26
|
+
"""
|
|
27
|
+
super().__init__(api, uuid=uuid, data=data)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@classmethod
|
|
31
|
+
async def get_versions(cls, api: 'AsyncGeoboxClient', **kwargs) -> Union[List['VectorLayerVersion'], int]:
|
|
32
|
+
"""
|
|
33
|
+
[async] Get list of versions with optional filtering and pagination.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
37
|
+
|
|
38
|
+
Keyword Args:
|
|
39
|
+
layer_id (str): the id of the vector layer.
|
|
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 versions. default is False.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
List[VectorLayerVersion] | int: A list of vector layer version instances or the total number of versions.
|
|
52
|
+
|
|
53
|
+
Example:
|
|
54
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
55
|
+
>>> from geobox.aio.version import VectorLayerVersion
|
|
56
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
57
|
+
>>> versions = await VectorLayerVersion.get_versions(client, q="name LIKE '%My version%'")
|
|
58
|
+
or
|
|
59
|
+
>>> versions = await client.get_versions(q="name LIKE '%My version%'")
|
|
60
|
+
"""
|
|
61
|
+
params = {
|
|
62
|
+
'layer_id': kwargs.get('layer_id'),
|
|
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: VectorLayerVersion(api, item['uuid'], item))
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
async def get_version(cls, api: 'AsyncGeoboxClient', uuid: str, user_id: int = None) -> 'VectorLayerVersion':
|
|
79
|
+
"""
|
|
80
|
+
[async] Get a version by its UUID.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
84
|
+
uuid (str): The UUID of the version to get.
|
|
85
|
+
user_id (int, optional): Specific user. privileges required.
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
VectorLayerVersion: The vector layer version object.
|
|
89
|
+
|
|
90
|
+
Raises:
|
|
91
|
+
NotFoundError: If the version with the specified UUID is not found.
|
|
92
|
+
|
|
93
|
+
Example:
|
|
94
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
95
|
+
>>> from geobox.aio.version import VectorLayerVersion
|
|
96
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
97
|
+
>>> version = await VectorLayerVersion.get_version(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
98
|
+
or
|
|
99
|
+
>>> version = await client.get_version(uuid="12345678-1234-5678-1234-567812345678")
|
|
100
|
+
"""
|
|
101
|
+
params = {
|
|
102
|
+
'f': 'json',
|
|
103
|
+
'user_id': user_id,
|
|
104
|
+
}
|
|
105
|
+
return await super()._get_detail(api, cls.BASE_ENDPOINT, uuid, params, factory_func=lambda api, item: VectorLayerVersion(api, item['uuid'], item))
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@classmethod
|
|
109
|
+
async def get_version_by_name(cls, api: 'AsyncGeoboxClient', name: str, user_id: int = None) -> 'VectorLayerVersion':
|
|
110
|
+
"""
|
|
111
|
+
[async] Get a version by name
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
115
|
+
name (str): the name of the version to get
|
|
116
|
+
user_id (int, optional): specific user. privileges required.
|
|
117
|
+
|
|
118
|
+
Returns:
|
|
119
|
+
VectorLayerVersion | None: returns the version if a version matches the given name, else None
|
|
120
|
+
|
|
121
|
+
Example:
|
|
122
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
123
|
+
>>> from geobox.aio.version import VectorLayerVersion
|
|
124
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
125
|
+
>>> version = await VectorLayerView.get_version_by_name(client, name='test')
|
|
126
|
+
or
|
|
127
|
+
>>> version = await client.get_version_by_name(name='test')
|
|
128
|
+
"""
|
|
129
|
+
versions = await cls.get_versions(api, q=f"name = '{name}'", user_id=user_id)
|
|
130
|
+
if versions and versions[0].name == name:
|
|
131
|
+
return versions[0]
|
|
132
|
+
else:
|
|
133
|
+
return None
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
async def update(self, **kwargs) -> Dict:
|
|
137
|
+
"""
|
|
138
|
+
[async] Update the version.
|
|
139
|
+
|
|
140
|
+
Args:
|
|
141
|
+
name (str): The name of the version.
|
|
142
|
+
display_name (str): The display name of the version.
|
|
143
|
+
description (str): The description of the version.
|
|
144
|
+
|
|
145
|
+
Returns:
|
|
146
|
+
Dict: The updated version data.
|
|
147
|
+
|
|
148
|
+
Raises:
|
|
149
|
+
ValidationError: If the version data is invalid.
|
|
150
|
+
|
|
151
|
+
Example:
|
|
152
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
153
|
+
>>> from geobox.aio.version import VectorLayerVersion
|
|
154
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
155
|
+
>>> version = await VectorLayerVersion.get_version(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
156
|
+
>>> await version.update_version(display_name="New Display Name")
|
|
157
|
+
"""
|
|
158
|
+
data = {
|
|
159
|
+
"name": kwargs.get('name'),
|
|
160
|
+
"display_name": kwargs.get('display_name'),
|
|
161
|
+
"description": kwargs.get('description'),
|
|
162
|
+
}
|
|
163
|
+
return await super()._update(self.endpoint, data)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
async def delete(self) -> None:
|
|
167
|
+
"""
|
|
168
|
+
[async] Delete the version.
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
None
|
|
172
|
+
|
|
173
|
+
Example:
|
|
174
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
175
|
+
>>> from geobox.aio.version import VectorLayerVersion
|
|
176
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
177
|
+
>>> version = await VectorLayerVersion.get_version(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
178
|
+
>>> await version.delete()
|
|
179
|
+
"""
|
|
180
|
+
await super().delete(self.endpoint)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
async def share(self, users: List['User']) -> None:
|
|
184
|
+
"""
|
|
185
|
+
[async] Shares the version with specified users.
|
|
186
|
+
|
|
187
|
+
Args:
|
|
188
|
+
users (List[User]): The list of user objects to share the version with.
|
|
189
|
+
|
|
190
|
+
Returns:
|
|
191
|
+
None
|
|
192
|
+
|
|
193
|
+
Example:
|
|
194
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
195
|
+
>>> from geobox.aio.version import VectorLayerVersion
|
|
196
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
197
|
+
>>> version = await VectorLayerVersion.get_version(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
198
|
+
>>> users = await client.search_users(search='John')
|
|
199
|
+
>>> await version.share(users=users)
|
|
200
|
+
"""
|
|
201
|
+
await super()._share(self.endpoint, users)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
async def unshare(self, users: List['User']) -> None:
|
|
205
|
+
"""
|
|
206
|
+
[async] Unshares the version with specified users.
|
|
207
|
+
|
|
208
|
+
Args:
|
|
209
|
+
users (List[User]): The list of user objects to unshare the version with.
|
|
210
|
+
|
|
211
|
+
Returns:
|
|
212
|
+
None
|
|
213
|
+
|
|
214
|
+
Example:
|
|
215
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
216
|
+
>>> from geobox.aio.version import VectorLayerVersion
|
|
217
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
218
|
+
>>> version = await VectorLayerVersion.get_version(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
219
|
+
>>> users = await client.search_users(search='John')
|
|
220
|
+
>>> await version.unshare(users=users)
|
|
221
|
+
"""
|
|
222
|
+
await super()._unshare(self.endpoint, users)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
async def get_shared_users(self, search: str = None, skip: int = 0, limit: int = 10) -> List['User']:
|
|
226
|
+
"""
|
|
227
|
+
[async] Retrieves the list of users the version is shared with.
|
|
228
|
+
|
|
229
|
+
Args:
|
|
230
|
+
search (str, optional): The search query.
|
|
231
|
+
skip (int, optional): The number of users to skip.
|
|
232
|
+
limit (int, optional): The maximum number of users to retrieve.
|
|
233
|
+
|
|
234
|
+
Returns:
|
|
235
|
+
List[User]: The list of shared users.
|
|
236
|
+
|
|
237
|
+
Example:
|
|
238
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
239
|
+
>>> from geobox.aio.version import VectorLayerVersion
|
|
240
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
241
|
+
>>> version = await VectorLayerVersion.get_version(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
242
|
+
>>> await version.get_shared_users(search='John', skip=0, limit=10)
|
|
243
|
+
"""
|
|
244
|
+
params = {
|
|
245
|
+
'search': search,
|
|
246
|
+
'skip': skip,
|
|
247
|
+
'limit': limit
|
|
248
|
+
}
|
|
249
|
+
return await super()._get_shared_users(self.endpoint, params)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def to_sync(self, sync_client: 'SyncGeoboxClient') -> 'SyncVectorLayerVersion':
|
|
253
|
+
"""
|
|
254
|
+
Switch to sync version of the version instance to have access to the sync methods
|
|
255
|
+
|
|
256
|
+
Args:
|
|
257
|
+
sync_client (SyncGeoboxClient): The sync version of the GeoboxClient instance for making requests.
|
|
258
|
+
|
|
259
|
+
Returns:
|
|
260
|
+
geobox.version.VectorLayerVersion: the sync instance of the version.
|
|
261
|
+
|
|
262
|
+
Example:
|
|
263
|
+
>>> from geobox import Geoboxclient
|
|
264
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
265
|
+
>>> from geobox.aio.version import VectorLayerversion
|
|
266
|
+
>>> client = GeoboxClient()
|
|
267
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
268
|
+
>>> version = await async_client.get_version(async_client, uuid="12345678-1234-5678-1234-567812345678")
|
|
269
|
+
>>> sync_version = version.to_sync(client)
|
|
270
|
+
"""
|
|
271
|
+
from ..version import VectorLayerVersion as SyncVectorLayerVersion
|
|
272
|
+
|
|
273
|
+
return SyncVectorLayerVersion(api=sync_client, uuid=self.uuid, data=self.data)
|