Layout

The Layout module provides functionality for working with layouts.

class Layout(api, uuid, data={})[source]

Bases: Base

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

Initialize a layout instance.

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • uuid (str) – The unique identifier for the layout.

  • data (Dict) – The data of the layout.

classmethod get_layouts(api, **kwargs)[source]

Get list of layouts with optional filtering and pagination.

Parameters:

api (GeoboxClient) – The GeoboxClient instance for making requests.

Keyword Arguments:
  • q (str) – query filter based on OGC CQL standard. e.g. “field1 LIKE ‘%GIS%’ AND created_at > ‘2021-01-01’”

  • 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.

  • search_fields (str) – comma separated list of fields for searching.

  • 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.

  • return_count (bool) – Whether to return total count. default is False.

  • skip (int) – Number of items to skip. default is 0.

  • limit (int) – Number of items to return. default is 10.

  • user_id (int) – Specific user. privileges required.

  • shared (bool) – Whether to return shared layouts. default is False.

Returns:

A list of layout instances or the total number of layouts.

Return type:

List[Layout] | int

Example

>>> from geobox import GeoboxClient
>>> from geobox.layout import Layout
>>> client = GeoboxClient()
>>> layouts = Layout.get_layout(client, q="name LIKE '%My layout%'")
or
>>> layouts = client.get_layout(q="name LIKE '%My layout%'")
classmethod create_layout(api, name, display_name=None, description=None, settings={}, thumbnail=None, user_id=None)[source]

Create a new layout.

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • name (str) – The name of the Layout.

  • display_name (str) – The display name of the layout.

  • description (str) – The description of the layout.

  • settings (Dict) – The settings of the layout.

  • thumbnail (str) – The thumbnail of the layout.

  • user_id (int) – Specific user. privileges layout.

Returns:

The newly created layout instance.

Return type:

Layout

Raises:

ValidationError – If the layout data is invalid.

Example

>>> from geobox import GeoboxClient
>>> from geobox.layout import Layout
>>> client = GeoboxClient()
>>> layout = Layout.create_layout(client, name="my_layout")
or
>>> layout = client.create_layout(name="my_layout")
classmethod get_layout(api, uuid, user_id=None)[source]

Get a layout by its UUID.

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • uuid (str) – The UUID of the layout to get.

  • user_id (int) – Specific user. privileges required.

Returns:

The layout object.

Return type:

Layout

Raises:

NotFoundError – If the layout with the specified UUID is not found.

Example

>>> from geobox import GeoboxClient
>>> from geobox.layout import Layout
>>> client = GeoboxClient()
>>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
or
>>> layout = client.get_layout(uuid="12345678-1234-5678-1234-567812345678")
classmethod get_layout_by_name(api, name, user_id=None)[source]

Get a layout by name

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • name (str) – the name of the layout to get

  • user_id (int, optional) – specific user. privileges required.

Returns:

returns the layout if a layout matches the given name, else None

Return type:

Layout | None

Example

>>> from geobox import GeoboxClient
>>> from geobox.layout import Layout
>>> client = GeoboxClient()
>>> layout = Layout.get_layout_by_name(client, name='test')
or
>>> layout = client.get_layout_by_name(name='test')
update(**kwargs)[source]

Update the layout.

Keyword Arguments:
  • name (str) – The name of the layout.

  • display_name (str) – The display name of the layout.

  • description (str) – The description of the layout.

  • settings (Dict) – The settings of the layout.

  • thumbnail (str) – The thumbnail of the layout.

Returns:

The updated layout data.

Return type:

Dict

Raises:

ValidationError – If the layout data is invalid.

Example

>>> from geobox import GeoboxClient
>>> from geobox.layout import Layout
>>> client = GeoboxClient()
>>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
>>> layout.update(display_name="New Display Name")
delete()[source]

Delete the Layout.

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.layout import Layout
>>> client = GeoboxClient()
>>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
>>> layout.delete()
property thumbnail: str

Get the thumbnail URL of the Layout.

Returns:

The thumbnail of the Layout.

Return type:

str

Example

>>> from geobox import GeoboxClient
>>> from geobox.layout import Layout
>>> client = GeoboxClient()
>>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
>>> layout.thumbnail
share(users)[source]

Shares the layout with specified users.

Parameters:

users (List[User]) – The list of user objects to share the layout with.

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.layout import Layout
>>> client = GeoboxClient()
>>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
>>> users = client.search_users(search='John')
>>> layout.share(users=users)
unshare(users)[source]

Unshares the layout with specified users.

Parameters:

users (List[User]) – The list of user objects to unshare the layout with.

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.layout import Layout
>>> client = GeoboxClient()
>>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
>>> users = client.search_users(search='John')
>>> layout.unshare(users=users)
get_shared_users(search=None, skip=0, limit=10)[source]

Retrieves the list of users the layout is shared with.

Parameters:
  • search (str, optional) – The search query.

  • skip (int, optional) – The number of users to skip.

  • limit (int, optional) – The maximum number of users to retrieve.

Returns:

The list of shared users.

Return type:

List[User]

Example

>>> from geobox import GeoboxClient
>>> from geobox.layout import Layout
>>> client = GeoboxClient()
>>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
>>> layout.get_shared_users(search='John', skip=0, limit=10)