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