externalId field uniquely identifies each relationship.
To define and manage the available relationship types, use the labels resource type. For example, you can define and use the following labels as relationship types:
flowsTo- to describe the flow between assets.belongsTo- to describe that a file resource belongs to a particular asset resource.isParentOf- to build a hierarchy of assets.implements- to describe that a physical item implements a functional asset at a specific point in time.
These labels are informational only, and they’re case-sensitive, for example,
flowsTo and FlowsTo aren’t the same.About relationships
Typically, asset resources originate from a maintenance system, and the hierarchical structure of the maintenance system often defines how the asset resources are organized in Cognite Data Fusion (CDF). The relationships resource type lets you organize the assets in other structures in addition to the standard hierarchical asset structure. For example, you can organize the assets by their physical location, where the grouping nodes in the hierarchy are buildings and floors rather than systems and functions. Another example is to build a graph structure that lets you navigate assets by mimicking their physical connections through wires or pipes. Before you create a relationship, make sure that the relationship type exists as a label. When you create a relationship, you must specify its type using theexternalId of the relevant label.
When you create a relationship, it’s good practice to add them to a data set for grouping and governance.
It’s not a requirement that the source or target resource exist when you create a relationship. This lets you create relationships between objects that don’t yet exist in CDF.
Create a relationship between two assets
To create a relationship, you need to give it an ID and a type and specify the source and target resource objects the relationship connects. The relationship ID must be anexternalId. The relationship type must be the externalId of a label.
Create relationships within a data set for logical grouping and governance.
This example request creates a relationship:
Create a relationship between a file and an asset
You can use relationships to create links between any resources by specifying thesourceType and targetType.
This example shows how to create a relationship of type belongsTo between a file and an asset resource.
Create a time-ranged relationship between two assets
When you have physical equipment as part of the asset resources, you can use relationships to capture how physical equipment serves at different functional locations over time. You can specify the timespan a relationship is valid for by specifying thestartTime and endTime properties.
This example shows how to create a relationship between two assets with a time range.
List relationships
To list existing relationships, use:List relationships for a particular asset
Relationships are directional. Therefore, we split this into two calls, one where the asset is the source and one where the asset is the target.List relationships of a particular type for a particular asset
To retrieve allflowsTo relationships of asset_1.
List relationship for an asset at a specific point in time
To list all time-ranged relationships of an asset with typeimplements and valid at a specific point in time, use: