import { KuzzleRequest } from "kuzzle"; import { JSONObject, KDocument, KHit, SearchResult } from "kuzzle-sdk"; import { DecodedMeasurement } from "../measure"; import { DeviceManagerPlugin } from "../plugin"; import { DigitalTwinService, Metadata, SearchParams } from "../shared"; import { AssetContent } from "./../asset"; import { ApiDeviceLinkAssetRequest } from "./types/DeviceApi"; import { DeviceContent } from "./types/DeviceContent"; export declare class DeviceService extends DigitalTwinService { constructor(plugin: DeviceManagerPlugin); registerAskEvents(): void; private _create; /** * Create a new device. * * @todo creating a device in the "device-manager" index should be a separate * method since in this case "engineId" is not really an engine ID but still * required as an argument (in part to check the tenant rights) */ create(model: string, reference: string, metadata: JSONObject, request: KuzzleRequest): Promise>; get(engineId: string, deviceId: string, request: KuzzleRequest): Promise>; private getInternalDevices; /** * Replace a device metadata */ replaceMetadata(engineId: string, deviceId: string, metadata: Metadata, request: KuzzleRequest): Promise>; /** * Update or Create an device metadata */ upsert(engineId: string, model: string, reference: string, metadata: Metadata, request: KuzzleRequest): Promise>; update(engineId: string, deviceId: string, metadata: Metadata, request: KuzzleRequest): Promise>; delete(engineId: string, deviceId: string, request: KuzzleRequest): Promise; search(engineId: string, searchParams: SearchParams, request: KuzzleRequest): Promise>>; /** * Internal logic to attach the device to an engine * * @param engineId Engine id to attach to * @param deviceId Device id to attach * @param options.refresh Wait for ES indexation * @param options.strict If true, throw if an operation isn't possible */ private _attachEngine; /** * Attach the device to an engine * * @param engineId Engine id to attach to * @param deviceId Device id to attach * @param options.refresh Wait for ES indexation * @param options.strict If true, throw if an operation isn't possible */ attachEngine(engineId: string, deviceId: string, request: KuzzleRequest): Promise>; /** * Detach a device from its attached engine * * @param {string} deviceId Id of the device * @param {KuzzleRequest} request kuzzle request */ detachEngine(deviceId: string, request: KuzzleRequest): Promise>; /** * Link a device to an asset. */ linkAsset(engineId: string, deviceId: string, assetId: string, measureNames: ApiDeviceLinkAssetRequest["body"]["measureNames"], implicitMeasuresLinking: boolean, request: KuzzleRequest): Promise<{ asset: KDocument; device: KDocument; }>; receiveMeasures(engineId: string, deviceId: string, measures: DecodedMeasurement[], payloadUuids: string[], request: KuzzleRequest): Promise; /** * Checks if the asset does not already have a linked device using one of the * requested measure names. */ private checkAlreadyProvidedMeasures; /** * Goes through the device available measures and add them into the link if: * - they are not already provided by another device * - they are not already present in the link request * - they are declared in the asset model */ private generateMissingAssetMeasureNames; /** * Internal logic of unlink a device of an asset * * @param {string} deviceId Id of the device * @param {KuzzleRequest} request kuzzle request */ private _unlinkAsset; /** * Unlink a device of an asset with lock * * @param {string} deviceId Id of the device * @param {KuzzleRequest} request kuzzle request */ unlinkAsset(deviceId: string, request: KuzzleRequest): Promise<{ asset: KDocument; device: KDocument; }>; private checkEngineExists; private checkAttachedToEngine; private getEngine; private getDeviceModel; private getAssetModel; }