Asset API#

Assets#

Example Use Inside of an Adapter Action

@action()
async def create_assets(self, actx: ActionExecutionContext, loading_config_id: str) -> t.List[str]:
    assets = await self.artificial_api.asset_api_v1.fetch_loading_config(actx=actx, load_config_id=loading_config_id)
    return await self.artificial_api.asset_api_v1.create(actx=actx, assets=assets, cleanup_with_job=True)

For more information on asset states, see Asset States.

class Asset(
definition_id: str,
id: str = '',
parent_id: str = '',
parent_socket_idx: int = 0,
offset_translation: ~typing.Tuple[float,
float,
float] = (0,
0,
0),
offset_rotation: ~typing.Tuple[float,
float,
float] = (0,
0,
0),
display_name: str = '',
lab_id: str = '',
ops_state: int = 0,
assistance_state: int = 0,
properties: ~typing.Dict[str,
None | str | int | float | bool | bytes | ~google.protobuf.message.Message] = <factory>,
invisible: bool = False,
archived: bool = False,
color: str = '',
temporal_job_id: str = '',
)#

Data representing an asset in the Artificial Digital Twin

Variables:
  • definition_id – The ID of the definitional asset, or type of asset this is

  • id – The ID of this asset

  • parent_id – The ID of the parent asset it is socketed into

  • parent_socket_idx – The index of the parent socket this asset is socketed into

  • offset_translation – The translation offset of the asset

  • offset_rotation – The rotation offset of the asset

  • display_name – The display name of the asset

  • lab_id – The ID of the lab the asset is in

  • ops_state – The operational state of the asset

  • assistance_state – The assistance state of the asset

  • properties – The properties of the asset

  • invisible – Whether the asset is invisible

  • archived – Whether the asset is archived

  • color – The color of the asset

  • temporal_job_id – Set this to the ID of the job that when completed or cancelled will remove the asset from the scene

class Create(
definition_id: str,
parent_id: str = '',
parent_socket_idx: int = 0,
offset_translation: ~typing.Tuple[float,
float,
float] = (0,
0,
0),
offset_rotation: ~typing.Tuple[float,
float,
float] = (0,
0,
0),
display_name: str = '',
lab_id: str = '',
ops_state: int = 0,
assistance_state: int = 0,
properties: ~typing.Dict[str,
None | str | int | float | bool | bytes | ~google.protobuf.message.Message] = <factory>,
invisible: bool = False,
color: str = '',
temporal_job_id: str = '',
)#

Data for creating a new asset in the Artificial Digital Twin Shares a subset of fields of an Asset. Definition ID must be set on create

class Match(
display_name: str | None = None,
definition_id: str | None = None,
parent_id: str | None = None,
parent_socket_idx: int | None = None,
ops_state: int | None = None,
assistance_state: int | None = None,
properties: ~typing.Dict[str,
None | str | int | float | bool | bytes | ~google.protobuf.message.Message] = <factory>,
invisible: bool | None = None,
archived: bool | None = None,
color: str | None = None,
temporal_job_id: str | None = None,
)#

Data for querying assets. Any asset that matches a field set will be returned Shares a subset of fields of an Asset.

class Update(
id: str,
display_name: str | None = None,
parent_id: str | None = None,
parent_socket_idx: int | None = None,
offset_translation: ~typing.Tuple[float,
float,
float] | None = None,
offset_rotation: ~typing.Tuple[float,
float,
float] | None = None,
ops_state: int | None = None,
assistance_state: int | None = None,
properties: ~typing.Dict[str,
None | str | int | float | bool | bytes | ~google.protobuf.message.Message] = <factory>,
invisible: bool | None = None,
color: str | None = None,
)#

Data for updating an asset in the Artificial Digital Twin Shares a subset of fields of an Asset. ID must be specified to update an asset

class AssetApi(connections: Connections)#

Provides an interface to interact with assets in the Artificial Digital Twin

async create(
*,
actx: ActionContext,
assets: List[Create],
cleanup_with_job: bool = False,
) List[str]#
async create(
*,
lab_id: str,
job_id: str,
assets: List[Create],
) List[str]
async create(
*,
lab_id: str,
assets: List[Create],
) List[str]

Creates assets in Artificial Digital Twin

Parameters:
  • actx – ActionContext or ActionExecutionContext of the action

  • assets – List of Assets to create, if Asset is passed in not all fields may be skipped

  • cleanup_with_job – If True, the assets will be cleaned up when the job completes or is cancelled

Returns:

List of Asset IDs created

async delete(
*,
actx: ActionContext,
ids: List[str],
) List[str]#
async delete(*, lab_id: str, ids: List[str]) List[str]

Deletes assets in Artificial Digital Twin

Parameters:
  • actx – ActionContext or ActionExecutionContext of the action

  • ids – Asset IDs to delete in the lab

Returns:

Deleted IDs

async fetch_loading_config(
*,
actx: ActionContext,
load_config_id: str,
) List[Create]#
async fetch_loading_config(
*,
lab_id: str,
load_config_id: str,
) List[Create]

Fetch a Loading Config for a lab

Parameters:
  • actx – ActionContext or ActionExecutionContext of the action

  • load_config_id – ID of the loading config to fetch

Raises:

ValueError – Raises if it does not find the loading config

Returns:

Returns a list containing data to create assets

async get(
*,
actx: ActionContext,
ids: List[str],
) List[Asset]#
async get(
*,
lab_id: str,
ids: List[str],
) List[Asset]

Retrieve assets from Artificial Digital Twin

Parameters:
  • actx – ActionContext or ActionExecutionContext of the action

  • ids – ID’s to fetch

Returns:

List of Assets and their properties

async query(
*,
actx: ActionContext,
match: Match,
) List[Asset]#
async query(
*,
lab_id: str,
match: Match,
) List[Asset]

Query for assets in the Artificial Digital Twin based on the match criteria

Parameters:
  • actx – ActionContext or ActionExecutionContext of the action

  • match – The criteria to match assets on

Returns:

A list of matching Assets and their properties

async update(
*,
actx: ActionContext,
updates: List[Update],
) None#
async update(
*,
lab_id: str,
updates: List[Update],
) None

Updates assets in the Artificial Digital Twin

Parameters:
  • actx – ActionContext or ActionExecutionContext of the action

  • updates – List of asset updates to apply