Attachment

This module provides functionality for working with attachments.

class Attachment(api, attachment_id, data={})[source]

Bases: Base

Parameters:
BASE_ENDPOINT = 'attachments/'
__init__(api, attachment_id, data={})[source]

Initialize an Attachment instance.

Parameters:
  • api (GeoboxClient) – The GeoboxClient 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

property file: File

Attachment file property

Returns:

the file object

Return type:

File

classmethod get_attachments(api, resource, **kwargs)[source]

Get list of attachments with optional filtering and pagination.

Parameters:
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[Attachment] | int

Raises:

TypeError – if the resource type is not supported

Example

>>> from geobox import GeoboxClient
>>> from geobox.attachment import Attachment
>>> client = GeoboxClient()
>>> map = client.get_maps()[0]
>>> attachments = Attachment.get_attachments(client, resource=map, q="name LIKE '%My attachment%'")
or
>>> attachments = client.get_attachments(resource=map, q="name LIKE '%My attachment%'")
classmethod create_attachment(api, name, loc_x, loc_y, resource, file, feature=None, display_name=None, description=None)[source]

Create a new Attachment.

Parameters:
  • api (GeoboxClient) – The GeoboxClient 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 (Map | VectorLayer | VectorLayerView) – the resource object.

  • file (File) – the file object.

  • feature (Feature, 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:

Attachment

Raises:

ValidationError – If the Attachment data is invalid.

Example

>>> from geobox import GeoboxClient
>>> from geobox.attachment import Attachment
>>> client = GeoboxClient()
>>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
>>> feature = layer.get_feature(feature_id=1)
>>> file = client.get_file(uuid="12345678-1234-5678-1234-567812345678")
>>> attachment = Attachment.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 = 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")
classmethod update_attachment(api, attachment_id, **kwargs)[source]

Update the attachment.

Parameters:
  • api (GeoboxClient) – The GeoboxClient 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 import GeoboxClient
>>> from geobox.attachment import Attachment
>>> client = GeoboxClient()
>>> Attachment.update_attachment(client, attachment_id=1, display_name="New Display Name")
or
>>> client.update_attachment(attachment_id=1, display_name="New Display Name")
update(**kwargs)[source]

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 import GeoboxClient
>>> from geobox.attachment import Attachment
>>> client = GeoboxClient()
>>> attachment = Attachment.get_attachments(client)[0]
>>> attachment.update(display_name="New Display Name")
delete()[source]

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 import GeoboxClient
>>> from geobox.attachment import Attachment
>>> client = GeoboxClient()
>>> attachment = Attachment.get_attachments(client)[0]
>>> attachment.delete()
property thumbnail: str

Get the thumbnail URL of the attachment.

Returns:

The thumbnail of the scene.

Return type:

str

Example

>>> from geobox import GeoboxClient
>>> from geobox.attachment import Attachment
>>> client = GeoboxClient()
>>> attachment = Attachment.get_attachment(client, uuid="12345678-1234-5678-1234-567812345678")
>>> attachment.thumbnail