Add entity relationships
Relationships are a property of the entity data model that describe a predefined
relationship type
between multiple entities. Relationships provide the means for entities to
reference other entities to enable graph-like lookup capabilities for special
processing. You can think of the relationship as a directed edge pointing from
the source entity, the entity that has the relationship
component defined,
towards the target entity defined at relationship.related_entity_id
.
Publishing relationships
Integrations that produce entities can publish relationships directly on the entity that they send to the Entities API. In multi-node mesh environments, the relationship will be distributed to other nodes in the mesh on the entity.
See the reference for a full description of the different relationship types and any special Lattice UI behavior attached to them.
Example
The following example relates tracks to its detecting asset by using the
Relationships
and tracked_by
component:
Entity: {
// ...
Relationships: []*entitymanagerv1.RelationshipRequest{
{
RelatedEntityId: "<YOUR ASSET ENTITY ID>",
RelationshipId: "<UNIQUE IDENTIFIER>"
RelationshipType: &entitymanagerv1.RelationshipType{
Type: &entitymanagerv1.RelationshipType_TrackedBy{
TrackedBy: &entitymanagerv1.TrackedBy{
LastMeasurementTimestamp: timestamppb.New(time.Now().UTC()),
ActivelyTrackingSensors: &entitymanagerv1.Sensors{
Sensors: []*entitymanagerv1.Sensor{
{
SensorId: "<UNIQUE IDENTIFIER>",
OperationalState: entitymanagerv1.OperationalState_OPERATIONAL_STATE_OPERATIONAL,
SensorType: entitymanagerv1.SensorType_SENSOR_TYPE_RADAR,
SensorDescription: "Mock Radar Sensor",
LastDetectionTimestamp: timestamppb.New(time.Now().UTC()),
FieldsOfView: []*entitymanagerv1.FieldOfView{},
},
},
},
},
},
},
},
},
}