Asset V2 Typed References Guide#
This covers the Asset-Service v2 linking APIs.
Typed asset references allows for describing relationships between assets. It effectively allows users to create a property graph between assets.
Core Concepts/Vocabulary#
Asset Link Definition - describes and restricts relationships between specific types of Assets
Asset Link Binding - determines the allowed origin and target asset definitions of eventual Asset Links
Asset Link - a typed link between two active Assets
Asset Link Definition#
Creating a link between assets requires that an asset link definition exists. An asset link definition describes the relationship between two assets and can be uni or bidirectional e.g. childOf/parentOf. To check which link definitions are available use the simple list endpoint:
curl -X 'GET' \
'https://api.mnemonic.no/assets/v2/asset/link/definition?limit=25&offset=0&includeDeleted=false' \
-H 'accept: application/json'
This will return all active definitions and their active bindings. If you cannot find a definition that matches your use case then we will need to request that an Asset Service administrator creates a new one for you. Similarly, if a definition exists that matches your use case, but it lacks a binding, then contact an admin.
To fetch a single definition and its bindings, active and optionally deleted, we can use its dedicated GET endpoint:
curl -X 'GET' \
'https://api.mnemonic.no/assets/v2/asset/link/definition/{definitionIdOrShortname}}' \
-H 'accept: application/json'
Note
We ensure that definitions’ shortnames are unique.
Asset Link#
Having found the asset link definition that matches your use case it’s very straightforward to then create a link between two active assets.
Given two assets Demo Child Asset
and Demo Parent Asset
of type Host Asset and an
existing link definition called hierarchy
that allows links between host assets we can create the relationship between them thus:
curl -X 'POST' \
'https://devapi.mnemonic.no/assets/v2/asset/demoParentAsset/link?customer=mnemonic' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"target": "demoChildAsset",
"definition": "hierarchy",
"ttl": 0
}'
Having created the link we can now view all links from or to a given asset:
curl -X 'GET' \
'https://devapi.mnemonic.no/assets/v2/asset/demoParentAsset/link?customer=mnemonic&limit=25&offset=0&includeDeleted=false' \
-H 'accept: application/json'