Async Attachment
This module provides functionality for working with async attachments.
- class AsyncAttachment(api, attachment_id, data={})[source]
Bases:
AsyncBase- Parameters:
api (AsyncGeoboxClient)
attachment_id (str)
data (Dict | None)
- BASE_ENDPOINT = 'attachments/'
- __init__(api, attachment_id, data={})[source]
Initialize an Attachment instance.
- Parameters:
api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.
attachment_id (str) – The id for the attachment.
data (Dict, optional) – The data of the attachment.
- __repr__()[source]
Return a string representation of the attachment.
- Returns:
The string representation of the attachment.
- Return type:
str
- async classmethod get_attachments(api, resource, **kwargs)[source]
[async] Get list of attachments with optional filtering and pagination.
- Parameters:
api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.
resource (AsyncMap | AsyncVectorLayer | AsyncVectorLayerView) – options are: Map, Vector, View objects
- Keyword Arguments:
element_id (str) – the id of the element with attachment.
search (str) – search term for keyword-based searching among all textual fields.
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.
skip (int) – Number of items to skip. default is 0.
limit (int) – Number of items to return. default is 10.
return_count (bool) – Whether to return total count. default is False.
- Returns:
A list of attachments instances or the total number of attachments.
- Return type:
List[AsyncAttachment] | int
- Raises:
TypeError – if the resource type is not supported
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.attachment import AsyncAttachment >>> async with AsyncGeoboxClient() as client: >>> maps = await client.get_maps() >>> map = maps[0] >>> attachments = await AsyncAttachment.get_attachments(client, resource=map, q="name LIKE '%My attachment%'") or >>> attachments = await client.get_attachments(resource=map, q="name LIKE '%My attachment%'")
- async classmethod create_attachment(api, name, loc_x, loc_y, resource, file, feature=None, display_name=None, description=None)[source]
[async] Create a new Attachment.
- Parameters:
api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.
name (str) – The name of the scene.
loc_x (int) – x parameter of the attachment location.
loc_y (int) – y parameter of the attachment location.
resource (AsyncMap | AsyncVectorLayer | AsyncVectorLayerView) – the resource object.
file (AsyncFile) – the file object.
feature (AsyncFeature, optional) – the feature object.
display_name (str, optional) – The display name of the scene.
description (str, optional) – The description of the scene.
- Returns:
The newly created Attachment instance.
- Return type:
- Raises:
ValidationError – If the Attachment data is invalid.
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.attachment import AsyncAttachment >>> async with AsyncGeoboxClient() as client: >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678") >>> feature = await layer.get_feature(feature_id=1) >>> file = await client.get_file(uuid="12345678-1234-5678-1234-567812345678") >>> attachment = await AsyncAttachment.create_attachment(client, ... name="my_attachment", ... loc_x=30, ... loc_y=50, ... resource=layer, ... file=file, ... feature=feature, ... display_name="My Attachment", ... description="Attachment Description") or >>> attachment = await client.create_attachment(name="my_attachment", ... loc_x=30, ... loc_y=50, ... resource=layer, ... file=file, ... feature=feature, ... display_name="My Attachment", ... description="Attachment Description")
- async classmethod update_attachment(api, attachment_id, **kwargs)[source]
[async] Update the attachment.
- Parameters:
api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.
attachment_id (int) – the attachment id.
- Keyword Arguments:
name (str) – The name of the attachment.
display_name (str) – The display name of the attachment.
description (str) – The description of the attachment.
loc_x (int) – x parameter of the attachment location.
loc_y (int) – y parameter of the attachment location.
- Returns:
The updated attachment data.
- Return type:
Dict
- Raises:
ValidationError – If the attachment data is invalid.
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.attachment import AsyncAttachment >>> async with AsyncGeoboxClient() as client: >>> await AsyncAttachment.update_attachment(client, attachment_id=1, display_name="New Display Name") or >>> await client.update_attachment(attachment_id=1, display_name="New Display Name")
- async update(**kwargs)[source]
[async] Update the attachment.
- Keyword Arguments:
name (str) – The name of the attachment.
display_name (str) – The display name of the attachment.
description (str) – The description of the attachment.
loc_x (int) – x parameter of the attachment location.
loc_y (int) – y parameter of the attachment location.
- Returns:
The updated attachment data.
- Return type:
Dict
- Raises:
ValidationError – If the attachment data is invalid.
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.attachment import AsyncAttachment >>> async with AsyncGeoboxClient() as client: >>> attachment = await AsyncAttachment.get_attachments(client)[0] >>> await attachment.update(display_name="New Display Name")
- async delete()[source]
[async] Delete the scene.
- Returns:
None
- Raises:
ApiRequestError – If the API request fails.
ValidationError – If the scene data is invalid.
- Return type:
None
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.attachment import AsyncAttachment >>> async with AsyncGeoboxClient() as client: >>> attachment = await AsyncAttachment.get_attachments(client)[0] >>> await attachment.delete()
- property thumbnail: str
Get the thumbnail URL of the attachment.
- Returns:
The thumbnail of the scene.
- Return type:
str
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.attachment import AsyncAttachment >>> async with AsyncGeoboxClient() as client: >>> attachment = await AsyncAttachment.get_attachment(client, uuid="12345678-1234-5678-1234-567812345678") >>> attachment.thumbnail