Assets Class
Assets interface
Access to the assets endpoint.
The user is not expected to use this class directly. It is an attribute of the
Archivist
class.
For example instantiate an Archivist instance and execute the methods of the class:
with open(".auth_token", mode="r", encoding="utf-8") as tokenfile:
authtoken = tokenfile.read().strip()
# Initialize connection to Archivist
arch = Archivist(
"https://app.datatrails.ai",
authtoken,
)
asset = arch.assets.create(...)
- class archivist.assets._AssetsPublic(archivist_instance: Archivist)[source]
AssetsReader
Access to assets entities using CRUD interface. This class is usually accessed as an attribute of the Archivist or Public class.
- Parameters:
archivist (Archivist) --
Archivist
instance
- class archivist.assets._AssetsRestricted(archivist_instance: Archivist)[source]
AssetsRestricted
Access to assets entities using CRUD interface. This class is usually accessed as an attribute of the Archivist or Public class.
- Parameters:
archivist (Archivist) --
Archivist
instance
- count(*, props: dict[str, Any] | None = None, attrs: dict[str, Any] | None = None) int [source]
Count assets.
Counts number of assets that match criteria.
- Parameters:
props (dict) -- e.g. {"confirmation_status": "CONFIRMED" }
attrs (dict) -- e.g. {"arc_display_type": "door" }
- Returns:
integer count of assets.
- create(*, props: dict[str, Any] | None = None, attrs: dict[str, Any] | None = None, confirm: bool = False) Asset [source]
Create asset
Creates asset with defined properties and attributes.
- Parameters:
props (dict) -- Properties
attrs (dict) -- attributes of created asset.
confirm (bool) -- if True wait for asset to be confirmed.
- Returns:
Asset
instance
- create_from_data(data: dict[str, Any], *, confirm: bool = False) Asset [source]
Create asset
Creates asset with request body from data stream. Suitable for reading data from a file using json.load or yaml.load
- Parameters:
data (dict) -- request body of asset.
confirm (bool) -- if True wait for asset to be confirmed.
- Returns:
Asset
instance
- create_if_not_exists(data: dict[str, Any], *, confirm: bool = False) tuple[Asset, bool] [source]
Creates an asset and associated locations and attachments if asset does not already exist.
- Parameters:
data (dict) -- request body of asset.
confirm (bool) -- if True wait for asset to be confirmed.
A YAML representation of the data argument would be:
selector: - attributes: - arc_display_name behaviours - RecordEvidence attributes: arc_display_name: DataTrails Front Door arc_firmware_version: "1.0" arc_serial_number: das-j1-01 arc_description: Electronic door entry system to DataTrails France wavestone_asset_id: paris.france.datatrails.das location: identity: locations/xxxxxxxxxxxxxxxxxxxxxxxxxx location: selector: - display_name display_name: DataTrails Paris description: Sales and sales support for the French region latitude: 48.8339211, longitude: 2.371345, attributes: address: 5 Parvis Alan Turing, 75013 Paris, France wavestone_ext: managed attachments: - filename: functests/test_resources/doors/assets/entry-terminal.jpg content_type: image/jpg attachment: terminal entry
The 'selector' value is required and will usually specify the 'arc_display_name' as a secondary key. The keys in 'selector' must exist in the attributes of the asset.
If 'location' is specified then the 'selector' value is required and is used as a secondary key. Likewise the secondary key must exist in the attributes of the location.
Alternatively the identity of the location is specified - both are shown - choose one.
- Returns:
tuple of
Asset
instance, Boolean is True if asset already existed
- list(*, page_size: int | None = None, props: dict[str, Any] | None = None, attrs: dict[str, Any] | None = None)[source]
List assets.
Lists assets that match criteria.
- Parameters:
props (dict) -- optional e.g. {"tracked": "TRACKED" }
attrs (dict) -- optional e.g. {"arc_display_type": "door" }
page_size (int) -- optional page size. (Rarely used).
- Returns:
iterable that returns
Asset
instances
- publicurl(identity: str) str [source]
Read asset public url
Reads assets public url.
- Parameters:
identity (str) -- assets identity e.g. assets/xxxxxxxxxxxxxxxxxxxxxxx
- Returns:
str: publicurl as string
- read_by_signature(*, props: dict[str, Any] | None = None, attrs: dict[str, Any] | None = None) Asset [source]
Read Asset by signature.
Reads asset that meets criteria. Only one asset is expected.
- Parameters:
props (dict) -- e.g. {"tracked": "TRACKED" }
attrs (dict) -- e.g. {"arc_display_type": "door" }
- Returns:
Asset
instance
- wait_for_confirmation(identity: str) Asset [source]
Wait for asset to be confirmed.
Waits for asset to be confirmed.
- Parameters:
identity (str) -- identity of asset
- Returns:
True if asset is confirmed.
- wait_for_confirmed(*, props: dict[str, Any] | None = None, attrs: dict[str, Any] | None = None) bool [source]
Wait for assets to be confirmed.
Waits for all assets that match criteria to be confirmed.
- Parameters:
props (dict) -- e.g. {"tracked": "TRACKED" }
attrs (dict) -- e.g. {"arc_display_type": "door" }
- Returns:
True if all assets are confirmed.