Containers as Assets
Using DataTrails to Represent Containers
Represent Containers Using DataTrails
DataTrails Assets can be used to track the status, contents, location, and other key attributes of containers over time. This can also be done for containers within containers. For example, you may wish to track bags inside boxes that are inside a shipping container being transported on a train.
Create a Container Asset
Creating an Asset to represent a container is the same as creating any other asset. For more detail on this process, please see our
DataTrails Overview guide. For this example, we will create a simple asset that we will call Shipping Container
. Note that with DataTrails, we could also record more complex attributes such as size of the container, weight, location, or any other important details. For now, we will create a minimal Asset that includes the name and type.
Note: To use the YAML Runner you will need to install the
datatrails-archivist
python package.Click here for installation instructions.
---
steps:
- step:
action: ASSETS_CREATE_IF_NOT_EXISTS
description: Create a shipping container asset.
asset_label: Shipping Container
selector:
- attributes:
- arc_display_name
behaviours:
- RecordEvidence
proof_mechanism: SIMPLE_HASH
attributes:
arc_display_name: Shipping Container
arc_display_type: Shipping Container
confirm: true
cat > asset.json <<EOF
{
"behaviours": ["RecordEvidence"],
"proof_mechanism": "SIMPLE_HASH",
"attributes": {
"arc_display_name": "Shipping Container",
"arc_display_type": "Shipping Container"
}
}
EOF
Use curl
to POST
the asset, viewing the result with jq
:
curl -X POST \
-H "@$HOME/.datatrails/bearer-token.txt" \
-H "Content-Type: application/json" \
-d "@asset.json" \
https://app.datatrails.ai/archivist/v2/assets | jq
If errors occur, see Troubleshooting Token Generation
Associate an Item or Container with Another Container
Now that we have created a Shipping Container
Asset, we can create an Asset to represent an item or container within the Shipping Container. To do this, we will create another Asset and add a custom Asset Attribute
that links it to our Shipping Container. For example, let’s create an Asset to represent a box that is being transported within the Shipping Container.
Note: For this example, we used the custom attributewithin_container
, but you could use any key to associate the Assets that does not contain the reservedarc_
prefix.
Set the
Name
andType
Create the Box Click
Advanced Options
Add an Extended Attribute Click
ADD ATTRIBUTE
to setExtended Attributes
Add Attribute =
within_container
and Value =Shipping Container
Click
REGISTER ASSET
to complete the association of the box within the containerRepeat the above a few times, editing the
Name
to add several boxes within theShipping Container
Note: To use the YAML Runner you will need to install the
datatrails-archivist
python package.Click here for installation instructions.
---
steps:
- step:
action: ASSETS_CREATE_IF_NOT_EXISTS
description: Create a box asset and associate with Shipping Container.
asset_label: Box
selector:
- attributes:
- arc_display_name
behaviours:
- RecordEvidence
proof_mechanism: SIMPLE_HASH
attributes:
arc_display_name: Box-1
arc_display_type: Box
within_container: Shipping Container
confirm: true
Repeat the above a few times, editing the arc_display_name
to add several boxes within the Shipping Container
cat > asset-box.json <<EOF
{
"behaviours": ["RecordEvidence"],
"proof_mechanism": "SIMPLE_HASH",
"attributes": {
"arc_display_name": "Box-1",
"arc_display_type": "Box",
"within_container": "Shipping Container"
}
}
EOF
Use curl
to POST
the asset, viewing the result with jq
:
curl -X POST \
-H "@$HOME/.datatrails/bearer-token.txt" \
-H "Content-Type: application/json" \
-d "@asset-box.json" \
https://app.datatrails.ai/archivist/v2/assets | jq
Repeat the above a few times, editing the arc_display_name
to add several boxes within the Shipping Container
If errors occur, see Troubleshooting Token Generation
The Box(es)
have been recorded as being within the Shipping Container
.
List All Assets Associated With a Container
To retrieve all Assets associated with a container, you can run a query with a filter that will identify which Assets have the attribute within_container
set to the desired value. To list all Assets inside of Shipping Container
:
Select
Audit/Filter
in the navigation to filter Assets and Events within your tenancySelect
ADD FILTER
Select
Asset Attribute
, set the name towithin_container
and the value toShipping Container
Select
APPLY FILTERS
to view the subset of Assets createdFilter Assets and Events
Note: To use the YAML Runner you will need to install the
datatrails-archivist
python package.Click here for installation instructions.
---
steps:
- step:
action: ASSETS_LIST
description: List all assets within Shipping Container.
print_response: true
attrs:
within_container: Shipping Container
curl -g -X GET \
-H "$HOME/.datatrails/bearer-token.txt" \
"https://app.datatrails.ai/archivist/v2/assets?attributes.within_container=Shipping%20Container" | jq