geobox 2.1.0__py3-none-any.whl → 2.2.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 +61 -63
- geobox/aio/__init__.py +61 -63
- geobox/aio/api.py +491 -574
- 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 +35 -35
- 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 +88 -454
- geobox/aio/{analysis.py → raster_analysis.py} +153 -170
- 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 +316 -414
- geobox/aio/version.py +272 -273
- geobox/aio/view.py +1019 -983
- geobox/aio/workflow.py +340 -341
- geobox/api.py +14 -98
- 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 +31 -1
- geobox/feature.py +31 -10
- 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 +5 -368
- geobox/{analysis.py → raster_analysis.py} +108 -128
- 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 -110
- geobox/version.py +272 -272
- geobox/view.py +981 -981
- geobox/workflow.py +338 -339
- {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/METADATA +15 -1
- geobox-2.2.1.dist-info/RECORD +72 -0
- geobox-2.1.0.dist-info/RECORD +0 -70
- {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/WHEEL +0 -0
- {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/licenses/LICENSE +0 -0
- {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/top_level.txt +0 -0
geobox/aio/attachment.py
CHANGED
|
@@ -1,339 +1,341 @@
|
|
|
1
|
-
from typing import List, Dict, Optional, TYPE_CHECKING, Union
|
|
2
|
-
from urllib.parse import urljoin
|
|
3
|
-
|
|
4
|
-
from .base import AsyncBase
|
|
5
|
-
from .map import
|
|
6
|
-
from .vectorlayer import
|
|
7
|
-
from .view import
|
|
8
|
-
from .file import
|
|
9
|
-
from ..utils import clean_data
|
|
10
|
-
|
|
11
|
-
if TYPE_CHECKING:
|
|
12
|
-
from . import AsyncGeoboxClient
|
|
13
|
-
from .feature import Feature
|
|
14
|
-
from ..api import GeoboxClient
|
|
15
|
-
from ..attachment import Attachment
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class
|
|
19
|
-
|
|
20
|
-
BASE_ENDPOINT = 'attachments/'
|
|
21
|
-
|
|
22
|
-
def __init__(self,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"""
|
|
27
|
-
Initialize an Attachment instance.
|
|
28
|
-
|
|
29
|
-
Args:
|
|
30
|
-
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
31
|
-
attachment_id (str): The id for the attachment.
|
|
32
|
-
data (Dict, optional): The data of the attachment.
|
|
33
|
-
"""
|
|
34
|
-
super().__init__(api, data=data)
|
|
35
|
-
self.attachment_id = attachment_id
|
|
36
|
-
self.endpoint = f"{self.BASE_ENDPOINT}{str(self.attachment_id)}/"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def __repr__(self) -> str:
|
|
40
|
-
"""
|
|
41
|
-
Return a string representation of the attachment.
|
|
42
|
-
|
|
43
|
-
Returns:
|
|
44
|
-
str: The string representation of the attachment.
|
|
45
|
-
"""
|
|
46
|
-
return f"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
@property
|
|
50
|
-
def file(self) -> '
|
|
51
|
-
"""
|
|
52
|
-
Attachment file property
|
|
53
|
-
|
|
54
|
-
Returns:
|
|
55
|
-
File: the file object
|
|
56
|
-
"""
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
@classmethod
|
|
61
|
-
async def get_attachments(cls,
|
|
62
|
-
|
|
63
|
-
[
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
>>>
|
|
88
|
-
>>>
|
|
89
|
-
>>>
|
|
90
|
-
|
|
91
|
-
>>>
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
resource_type = '
|
|
98
|
-
|
|
99
|
-
elif type(resource) ==
|
|
100
|
-
resource_type = '
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
'
|
|
111
|
-
'
|
|
112
|
-
'
|
|
113
|
-
'
|
|
114
|
-
'
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
>>>
|
|
155
|
-
>>>
|
|
156
|
-
>>>
|
|
157
|
-
>>>
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
...
|
|
162
|
-
...
|
|
163
|
-
...
|
|
164
|
-
...
|
|
165
|
-
...
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
...
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
...
|
|
172
|
-
...
|
|
173
|
-
...
|
|
174
|
-
...
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if isinstance(resource,
|
|
180
|
-
resource_type = '
|
|
181
|
-
|
|
182
|
-
if isinstance(resource,
|
|
183
|
-
resource_type = '
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
"
|
|
190
|
-
"
|
|
191
|
-
"
|
|
192
|
-
"
|
|
193
|
-
"
|
|
194
|
-
"
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
>>>
|
|
226
|
-
|
|
227
|
-
>>>
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
"
|
|
234
|
-
"
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
>>>
|
|
263
|
-
>>>
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
"
|
|
270
|
-
"
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
>>>
|
|
293
|
-
>>>
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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
|
|
332
|
-
>>>
|
|
333
|
-
>>>
|
|
334
|
-
>>>
|
|
335
|
-
>>>
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
1
|
+
from typing import List, Dict, Optional, TYPE_CHECKING, Union
|
|
2
|
+
from urllib.parse import urljoin
|
|
3
|
+
|
|
4
|
+
from .base import AsyncBase
|
|
5
|
+
from .map import AsyncMap
|
|
6
|
+
from .vectorlayer import AsyncVectorLayer
|
|
7
|
+
from .view import AsyncVectorLayerView
|
|
8
|
+
from .file import AsyncFile
|
|
9
|
+
from ..utils import clean_data
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from . import AsyncGeoboxClient
|
|
13
|
+
from .feature import Feature
|
|
14
|
+
from ..api import GeoboxClient
|
|
15
|
+
from ..attachment import Attachment
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class AsyncAttachment(AsyncBase):
|
|
19
|
+
|
|
20
|
+
BASE_ENDPOINT = 'attachments/'
|
|
21
|
+
|
|
22
|
+
def __init__(self,
|
|
23
|
+
api: 'AsyncGeoboxClient',
|
|
24
|
+
attachment_id: str,
|
|
25
|
+
data: Optional[Dict] = {}):
|
|
26
|
+
"""
|
|
27
|
+
Initialize an Attachment instance.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
31
|
+
attachment_id (str): The id for the attachment.
|
|
32
|
+
data (Dict, optional): The data of the attachment.
|
|
33
|
+
"""
|
|
34
|
+
super().__init__(api, data=data)
|
|
35
|
+
self.attachment_id = attachment_id
|
|
36
|
+
self.endpoint = f"{self.BASE_ENDPOINT}{str(self.attachment_id)}/"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def __repr__(self) -> str:
|
|
40
|
+
"""
|
|
41
|
+
Return a string representation of the attachment.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
str: The string representation of the attachment.
|
|
45
|
+
"""
|
|
46
|
+
return f"AsyncAttachment(id={self.attachment_id}, name={self.name})"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def file(self) -> 'AsyncFile':
|
|
51
|
+
"""
|
|
52
|
+
Attachment file property
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
File: the file object
|
|
56
|
+
"""
|
|
57
|
+
return AsyncFile(self.api, self.data['file'].get('uuid'), self.data['file'])
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
async def get_attachments(cls,
|
|
62
|
+
api: 'AsyncGeoboxClient',
|
|
63
|
+
resource: Union['AsyncMap', 'AsyncVectorLayer', 'AsyncVectorLayerView'],
|
|
64
|
+
**kwargs) -> Union[List['AsyncAttachment'], int]:
|
|
65
|
+
"""
|
|
66
|
+
[async] Get list of attachments with optional filtering and pagination.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
70
|
+
resource (AsyncMap | AsyncVectorLayer | AsyncVectorLayerView): options are: Map, Vector, View objects
|
|
71
|
+
|
|
72
|
+
Keyword Args:
|
|
73
|
+
element_id (str): the id of the element with attachment.
|
|
74
|
+
search (str): search term for keyword-based searching among all textual fields.
|
|
75
|
+
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.
|
|
76
|
+
skip (int): Number of items to skip. default is 0.
|
|
77
|
+
limit (int): Number of items to return. default is 10.
|
|
78
|
+
return_count (bool): Whether to return total count. default is False.
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
List[AsyncAttachment] | int: A list of attachments instances or the total number of attachments.
|
|
82
|
+
|
|
83
|
+
Raises:
|
|
84
|
+
TypeError: if the resource type is not supported
|
|
85
|
+
|
|
86
|
+
Example:
|
|
87
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
88
|
+
>>> from geobox.aio.attachment import AsyncAttachment
|
|
89
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
90
|
+
>>> maps = await client.get_maps()
|
|
91
|
+
>>> map = maps[0]
|
|
92
|
+
>>> attachments = await AsyncAttachment.get_attachments(client, resource=map, q="name LIKE '%My attachment%'")
|
|
93
|
+
or
|
|
94
|
+
>>> attachments = await client.get_attachments(resource=map, q="name LIKE '%My attachment%'")
|
|
95
|
+
"""
|
|
96
|
+
if type(resource) == AsyncVectorLayer:
|
|
97
|
+
resource_type = 'vector'
|
|
98
|
+
|
|
99
|
+
elif type(resource) == AsyncVectorLayerView:
|
|
100
|
+
resource_type = 'view'
|
|
101
|
+
|
|
102
|
+
elif type(resource) == AsyncMap:
|
|
103
|
+
resource_type = 'map'
|
|
104
|
+
|
|
105
|
+
else:
|
|
106
|
+
raise TypeError('resource must be a vectorlayer or view or map object')
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
params = {
|
|
110
|
+
'resource_type': resource_type,
|
|
111
|
+
'resource_uuid': resource.uuid,
|
|
112
|
+
'element_id': kwargs.get('element_id'),
|
|
113
|
+
'search': kwargs.get('search'),
|
|
114
|
+
'order_by': kwargs.get('order_by'),
|
|
115
|
+
'skip': kwargs.get('skip', 0),
|
|
116
|
+
'limit': kwargs.get('limit', 10),
|
|
117
|
+
'return_count': kwargs.get('return_count')
|
|
118
|
+
}
|
|
119
|
+
return await super()._get_list(api, cls.BASE_ENDPOINT, params, factory_func=lambda api, item: AsyncAttachment(api, item['id'], item))
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
@classmethod
|
|
123
|
+
async def create_attachment(cls,
|
|
124
|
+
api: 'AsyncGeoboxClient',
|
|
125
|
+
name: str,
|
|
126
|
+
loc_x: int,
|
|
127
|
+
loc_y: int,
|
|
128
|
+
resource: Union['AsyncMap', 'AsyncVectorLayer', 'AsyncVectorLayerView'],
|
|
129
|
+
file: 'File',
|
|
130
|
+
feature: 'Feature' = None,
|
|
131
|
+
display_name: str = None,
|
|
132
|
+
description: str = None, ) -> 'AsyncAttachment':
|
|
133
|
+
"""
|
|
134
|
+
[async] Create a new Attachment.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
138
|
+
name (str): The name of the scene.
|
|
139
|
+
loc_x (int): x parameter of the attachment location.
|
|
140
|
+
loc_y (int): y parameter of the attachment location.
|
|
141
|
+
resource (AsyncMap | AsyncVectorLayer | AsyncVectorLayerView): the resource object.
|
|
142
|
+
file (File): the file object.
|
|
143
|
+
feature (Feature, optional): the feature object.
|
|
144
|
+
display_name (str, optional): The display name of the scene.
|
|
145
|
+
description (str, optional): The description of the scene.
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
AsyncAttachment: The newly created Attachment instance.
|
|
149
|
+
|
|
150
|
+
Raises:
|
|
151
|
+
ValidationError: If the Attachment data is invalid.
|
|
152
|
+
|
|
153
|
+
Example:
|
|
154
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
155
|
+
>>> from geobox.aio.attachment import AsyncAttachment
|
|
156
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
157
|
+
>>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
158
|
+
>>> feature = await layer.get_feature(feature_id=1)
|
|
159
|
+
>>> file = await client.get_file(uuid="12345678-1234-5678-1234-567812345678")
|
|
160
|
+
>>> attachment = await AsyncAttachment.create_attachment(client,
|
|
161
|
+
... name="my_attachment",
|
|
162
|
+
... loc_x=30,
|
|
163
|
+
... loc_y=50,
|
|
164
|
+
... resource=layer,
|
|
165
|
+
... file=file,
|
|
166
|
+
... feature=feature,
|
|
167
|
+
... display_name="My Attachment",
|
|
168
|
+
... description="Attachment Description")
|
|
169
|
+
or
|
|
170
|
+
>>> attachment = await client.create_attachment(name="my_attachment",
|
|
171
|
+
... loc_x=30,
|
|
172
|
+
... loc_y=50,
|
|
173
|
+
... resource=layer,
|
|
174
|
+
... file=file,
|
|
175
|
+
... feature=feature,
|
|
176
|
+
... display_name="My Attachment",
|
|
177
|
+
... description="Attachment Description")
|
|
178
|
+
"""
|
|
179
|
+
if isinstance(resource, AsyncVectorLayer):
|
|
180
|
+
resource_type = 'vector'
|
|
181
|
+
|
|
182
|
+
if isinstance(resource, AsyncVectorLayerView):
|
|
183
|
+
resource_type = 'view'
|
|
184
|
+
|
|
185
|
+
if isinstance(resource, AsyncMap):
|
|
186
|
+
resource_type = 'map'
|
|
187
|
+
|
|
188
|
+
data = {
|
|
189
|
+
"name": name,
|
|
190
|
+
"display_name": display_name,
|
|
191
|
+
"description": description,
|
|
192
|
+
"loc_x": loc_x,
|
|
193
|
+
"loc_y": loc_y,
|
|
194
|
+
"resource_type": resource_type,
|
|
195
|
+
"resource_uuid": resource.uuid,
|
|
196
|
+
"element_id": feature.id if feature else None,
|
|
197
|
+
"file_id": file.id
|
|
198
|
+
}
|
|
199
|
+
return await super()._create(api, cls.BASE_ENDPOINT, data, factory_func=lambda api, item: AsyncAttachment(api, item['id'], item))
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
@classmethod
|
|
203
|
+
async def update_attachment(cls, api: 'AsyncGeoboxClient', attachment_id: int, **kwargs) -> Dict:
|
|
204
|
+
"""
|
|
205
|
+
[async] Update the attachment.
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
|
|
209
|
+
attachment_id (int): the attachment id.
|
|
210
|
+
|
|
211
|
+
Keyword Args:
|
|
212
|
+
name (str): The name of the attachment.
|
|
213
|
+
display_name (str): The display name of the attachment.
|
|
214
|
+
description (str): The description of the attachment.
|
|
215
|
+
loc_x (int): x parameter of the attachment location.
|
|
216
|
+
loc_y (int): y parameter of the attachment location.
|
|
217
|
+
|
|
218
|
+
Returns:
|
|
219
|
+
Dict: The updated attachment data.
|
|
220
|
+
|
|
221
|
+
Raises:
|
|
222
|
+
ValidationError: If the attachment data is invalid.
|
|
223
|
+
|
|
224
|
+
Example:
|
|
225
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
226
|
+
>>> from geobox.aio.attachment import AsyncAttachment
|
|
227
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
228
|
+
>>> await AsyncAttachment.update_attachment(client, attachment_id=1, display_name="New Display Name")
|
|
229
|
+
or
|
|
230
|
+
>>> await client.update_attachment(attachment_id=1, display_name="New Display Name")
|
|
231
|
+
"""
|
|
232
|
+
data = clean_data({
|
|
233
|
+
"name": kwargs.get('name'),
|
|
234
|
+
"display_name": kwargs.get('display_name'),
|
|
235
|
+
"description": kwargs.get('description'),
|
|
236
|
+
"loc_x": kwargs.get('loc_x'),
|
|
237
|
+
"loc_y": kwargs.get('loc_y')
|
|
238
|
+
})
|
|
239
|
+
endpoint = urljoin(cls.BASE_ENDPOINT, str(attachment_id))
|
|
240
|
+
response = await api.put(endpoint, data)
|
|
241
|
+
return response
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
async def update(self, **kwargs) -> Dict:
|
|
245
|
+
"""
|
|
246
|
+
[async] Update the attachment.
|
|
247
|
+
|
|
248
|
+
Keyword Args:
|
|
249
|
+
name (str): The name of the attachment.
|
|
250
|
+
display_name (str): The display name of the attachment.
|
|
251
|
+
description (str): The description of the attachment.
|
|
252
|
+
loc_x (int): x parameter of the attachment location.
|
|
253
|
+
loc_y (int): y parameter of the attachment location.
|
|
254
|
+
|
|
255
|
+
Returns:
|
|
256
|
+
Dict: The updated attachment data.
|
|
257
|
+
|
|
258
|
+
Raises:
|
|
259
|
+
ValidationError: If the attachment data is invalid.
|
|
260
|
+
|
|
261
|
+
Example:
|
|
262
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
263
|
+
>>> from geobox.aio.attachment import AsyncAttachment
|
|
264
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
265
|
+
>>> attachment = await AsyncAttachment.get_attachments(client)[0]
|
|
266
|
+
>>> await attachment.update(display_name="New Display Name")
|
|
267
|
+
"""
|
|
268
|
+
data = clean_data({
|
|
269
|
+
"name": kwargs.get('name'),
|
|
270
|
+
"display_name": kwargs.get('display_name'),
|
|
271
|
+
"description": kwargs.get('description'),
|
|
272
|
+
"loc_x": kwargs.get('loc_x'),
|
|
273
|
+
"loc_y": kwargs.get('loc_y')
|
|
274
|
+
})
|
|
275
|
+
response = await self.api.put(self.endpoint, data)
|
|
276
|
+
self._update_properties(response)
|
|
277
|
+
return response
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
async def delete(self) -> None:
|
|
281
|
+
"""
|
|
282
|
+
[async] Delete the scene.
|
|
283
|
+
|
|
284
|
+
Returns:
|
|
285
|
+
None
|
|
286
|
+
|
|
287
|
+
Raises:
|
|
288
|
+
ApiRequestError: If the API request fails.
|
|
289
|
+
ValidationError: If the scene data is invalid.
|
|
290
|
+
|
|
291
|
+
Example:
|
|
292
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
293
|
+
>>> from geobox.aio.attachment import AsyncAttachment
|
|
294
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
295
|
+
>>> attachment = await AsyncAttachment.get_attachments(client)[0]
|
|
296
|
+
>>> await attachment.delete()
|
|
297
|
+
"""
|
|
298
|
+
await super()._delete(self.endpoint)
|
|
299
|
+
self.attachment_id = None
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
@property
|
|
303
|
+
def thumbnail(self) -> str:
|
|
304
|
+
"""
|
|
305
|
+
Get the thumbnail URL of the attachment.
|
|
306
|
+
|
|
307
|
+
Returns:
|
|
308
|
+
str: The thumbnail of the scene.
|
|
309
|
+
|
|
310
|
+
Example:
|
|
311
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
312
|
+
>>> from geobox.aio.attachment import AsyncAttachment
|
|
313
|
+
>>> async with AsyncGeoboxClient() as client:
|
|
314
|
+
>>> attachment = await AsyncAttachment.get_attachment(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
315
|
+
>>> attachment.thumbnail
|
|
316
|
+
"""
|
|
317
|
+
return super()._thumbnail(format='')
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def to_sync(self, sync_client: 'GeoboxClient') -> 'Attachment':
|
|
321
|
+
"""
|
|
322
|
+
Switch to sync version of the attachment instance to have access to the sync methods
|
|
323
|
+
|
|
324
|
+
Args:
|
|
325
|
+
sync_client (GeoboxClient): The sync version of the GeoboxClient instance for making requests.
|
|
326
|
+
|
|
327
|
+
Returns:
|
|
328
|
+
Attachment: the sync instance of the attachment.
|
|
329
|
+
|
|
330
|
+
Example:
|
|
331
|
+
>>> from geobox import Geoboxclient
|
|
332
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
333
|
+
>>> from geobox.aio.attachment import AsyncAttachment
|
|
334
|
+
>>> client = GeoboxClient()
|
|
335
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
336
|
+
>>> attachment = await AsyncAttachment.get_attachment(async_client, uuid="12345678-1234-5678-1234-567812345678")
|
|
337
|
+
>>> sync_attachment = attachment.to_sync(client)
|
|
338
|
+
"""
|
|
339
|
+
from ..attachment import Attachment
|
|
340
|
+
|
|
341
|
+
return Attachment(api=sync_client, attachment_id=self.attachment_id, data=self.data)
|