in src/modules/timestream_telemetry/lambda_function/udq_data_reader.py [0:0]
def get_iottwinmaker_reference(self) -> IoTTwinMakerReference:
"""
This function calculates the IoTTwinMakerReference ("entityPropertyReference") for a Timestream row
For single-entity queries, the entity_id and component_name values are passed in, use those to construct the 'EntityComponentPropertyRef'
For multi-entity queries, we don't have the IoT TwinMaker entity_id so we return back the property identifier stored in Timestream as an 'external_id_property'
"""
property_name = self._row_as_dict['measure_name']
if self._entity_id and self._component_name:
return IoTTwinMakerReference(ecp=EntityComponentPropertyRef(self._entity_id, self._component_name, property_name))
else:
return IoTTwinMakerReference(external_id_property={
# special case Alarm and map the externalId to alarm_key
'alarm_key' if self._telemetry_asset_type == 'Alarm' else 'telemetryAssetId': self._row_as_dict['TelemetryAssetId'],
'propertyName': property_name if property_name != 'Status' else 'alarm_status' # AWS IoT TwinMaker's alarm component in Grafana expects a particular property name for alarm telemetry
})