linkAsset #
Link a device to an asset.
The device measures will be copied into the asset.
Query Syntax #
HTTP #
URL: http://kuzzle:7512/_/device-manager/:index/devices/:_id/_linkAsset/:assetId[?refresh=wait_for]
Method: PUT
Other protocols #
{
"index": "<index>",
"controller": "device-manager/device",
"action": "linkAsset",
"_id": "<deviceId>",
"assetId": "<assetId>"
}
Kourou #
kourou device-manager/device:linkAsset <index> --id <deviceId> -a assetId=<assetId>
Arguments #
index
: Tenant index nameassetId
: Asset unique identifier
Optional: #
refresh
: if set towait_for
, Kuzzle will not respond until the documents are indexed
Response #
{
"status": 200,
"error": null,
"index": "<index>",
"controller": "device-manager/device",
"action": "linkAsset",
"requestId": "<unique request identifier>",
"result": {}
}
Events #
Two events when this action is called, allowing to modify the device before it is linked to the asset:
import set from 'lodash/set';
app.pipe.register('device-manager:device:link-asset:before', async ({ device, asset }) => {
app.log.debug('before link-asset triggered');
set(asset, 'body.metadata.enrichedByBeforeLinkAsset', true);
return { device, asset };
})
app.pipe.register('device-manager:device:link-asset:after', async ({ device, asset }) => {
app.log.debug('after link-asset triggered');
return { device, asset };
})
Edit this page on Github (opens new window)