Async Workflow
The async Workflow module provides functionality for working with workflows.
- class AsyncWorkflow(api, uuid, data={})[source]
Bases:
AsyncBase- Parameters:
api (AsyncGeoboxClient)
uuid (str)
data (Dict | None)
- BASE_ENDPOINT = 'workflows/'
- __init__(api, uuid, data={})[source]
Initialize an async workflow instance.
- Parameters:
api (GeoboxClient) – The GeoboxClient instance for making requests.
uuid (str) – The unique identifier for the workflow.
data (Dict) – The data of the workflow.
- async classmethod get_workflows(api, **kwargs)[source]
[async] Get list of workflows with optional filtering
- Parameters:
api (AsyncGeoboxClient) – The AsyncGeoboxClient 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 workflows. default is False.
- Returns:
A list of workflow instances or the total number of workflows.
- Return type:
List[AsyncWorkflow] | int
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.workflow import AsyncWorkflow >>> async with AsyncGeoboxClient() as client: >>> workflows = await AsyncWorkflow.get_workflows(client, q="name LIKE '%My workflow%'") or >>> workflows = await client.get_workflows(q="name LIKE '%My workflow%'")
- async classmethod create_workflow(api, name, display_name=None, description=None, settings={}, thumbnail=None, user_id=None)[source]
[async] Create a new workflow.
- Parameters:
api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.
name (str) – The name of the Workflow.
display_name (str) – The display name of the workflow.
description (str) – The description of the workflow.
settings (Dict) – The settings of the workflow.
thumbnail (str) – The thumbnail of the workflow.
user_id (int) – Specific user. privileges required.
- Returns:
The newly created workflow instance.
- Return type:
- Raises:
ValidationError – If the workflow data is invalid.
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.workflow import AsyncWorkflow >>> async with AsyncGeoboxClient() as client: >>> workflow = await AsyncWorkflow.create_workflow(client, name="my_workflow") or >>> workflow = await client.create_workflow(name="my_workflow")
- async classmethod get_workflow(api, uuid, user_id=None)[source]
[async] Get a workflow by its UUID.
- Parameters:
api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.
uuid (str) – The UUID of the workflow to get.
user_id (int) – Specific user. privileges required.
- Returns:
The workflow object.
- Return type:
- Raises:
NotFoundError – If the workflow with the specified UUID is not found.
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.workflow import AsyncWorkflow >>> async with AsyncGeoboxClient() as client: >>> workflow = await AsyncWorkflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678") or >>> workflow = await client.get_workflow(uuid="12345678-1234-5678-1234-567812345678")
- async classmethod get_workflow_by_name(api, name, user_id=None)[source]
[async] Get a workflow by name
- Parameters:
api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.
name (str) – the name of the workflow to get
user_id (int, optional) – specific user. privileges required.
- Returns:
returns the workflow if a workflow matches the given name, else None
- Return type:
AsyncWorkflow | None
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.workflow import AsyncWorkflow >>> async with AsyncGeoboxClient() as client: >>> workflow = await AsyncWorkflow.get_workflow_by_name(client, name='test') or >>> workflow = await client.get_workflow_by_name(name='test')
- async update(**kwargs)[source]
[async] Update the workflow.
- Keyword Arguments:
name (str) – The name of the workflow.
display_name (str) – The display name of the workflow.
description (str) – The description of the workflow.
settings (Dict) – The settings of the workflow.
thumbnail (str) – The thumbnail of the workflow.
- Returns:
The updated workflow data.
- Return type:
Dict
- Raises:
ValidationError – If the workflow data is invalid.
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.workflow import AsyncWorkflow >>> async with AsyncGeoboxClient() as client: >>> workflow = await AsyncWorkflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678") >>> await workflow.update_workflow(display_name="New Display Name")
- async delete()[source]
[async] Delete the Workflow.
- Returns:
None
- Return type:
None
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.workflow import AsyncWorkflow >>> async with AsyncGeoboxClient() as client: >>> workflow = await AsyncWorkflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678") >>> await workflow.delete()
- property thumbnail: str
Get the thumbnail URL of the Workflow.
- Returns:
The thumbnail of the Workflow.
- Return type:
str
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.workflow import AsyncWorkflow >>> async with AsyncGeoboxClient() as client: >>> workflow = await AsyncWorkflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678") >>> workflow.thumbnail
[async] Shares the workflow with specified users.
- Parameters:
users (List[AsyncUser]) – The list of user objects to share the workflow with.
- Returns:
None
- Return type:
None
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.workflow import AsyncWorkflow >>> async with AsyncGeoboxClient() as client: >>> workflow = await AsyncWorkflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678") >>> users = await client.search_users(search='John') >>> await workflow.share(users=users)
[async] Unshares the workflow with specified users.
- Parameters:
users (List[AsyncUser]) – The list of user objects to unshare the workflow with.
- Returns:
None
- Return type:
None
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.workflow import AsyncWorkflow >>> async with AsyncGeoboxClient() as client: >>> workflow = await AsyncWorkflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678") >>> users = await client.search_users(search='John') >>> await workflow.unshare(users=users)
[async] Retrieves the list of users the workflow 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[AsyncUser]
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.workflow import AsyncWorkflow >>> async with AsyncGeoboxClient() as client: >>> workflow = await AsyncWorkflow.get_workflow(client, uuid="12345678-1234-5678-1234-567812345678") >>> await workflow.get_shared_users(search='John', skip=0, limit=10)