Create a data analyzer
POST/api/v1/orgs/{orgId}/devices/{deviceId}/analyzers
Create a new analyzer to transform input data stream values using a mathematical expression or a JavaScript script. Analyzers are always created disabled; use the enable/disable action to activate.
Request Body
name(string, required): Human-readable analyzer name. Maximum length: 256.description(string, optional): Analyzer description. Maximum length: 500.type(AnalyzerType, required):TransferFunctionorJavaScript.inputParameters(array, required): Binds input data streams to the variable names used by the expression or script.TransferFunctionrequires exactly one;JavaScriptaccepts up to ten.config.expression(string): Required forTransferFunction.config.script(string): Required forJavaScript. Each input is a variable named after its parameter, holding the incoming value asvalueorvaland its source time in milliseconds astimestamports.outputs(array, required): Target data streams.TransferFunctionemits exactly one;JavaScriptmay emit several, each selecting from the script result withvalueJsonPathandtimeJsonPath.dataAssemblyPolicy(object, optional): Data Assembly settings. Valid only wheninputParametersholds two or more data streams; omit it to take the defaults.
Responses
201 Created: Analyzer created successfully.400 Bad Request: Invalid request, expression, or script; an expression or script that does not name every declared input parameter; a duplicate or self-referencing data stream, or more than ten inputs; a duplicate input parameter name; an unsupported JSONPath, or a JavaScript output without one; adataAssemblyPolicyvalue outside its range; or a dependency graph exceeding the maximum chain depth of five analyzers or containing a cycle.401 Unauthorized: Missing or invalid authentication token.403 Forbidden: The caller is not permitted to access this organization or device.404 Not Found: Device, input data stream, or output data stream not found.409 Conflict: The output data stream already has a data source: another analyzer, or a node, subnode, or device.500 Internal Server Error: An upstream service (device management, data streams, or Data Assembly) was unreachable or failed.
Security
- This API requires authentication.
Request
Responses
- 201
- 400
- 401
- 403
- 404
- 409
- 500
Created
Invalid request, expression, or script; an expression or script that does not name every declared input parameter; a duplicate or self-referencing data stream, or more than ten inputs; a duplicate input parameter name; an unsupported JSONPath, or a JavaScript output without one; a dataAssemblyPolicy value outside its range; or a dependency graph exceeding the maximum chain depth of five analyzers or containing a cycle.
Missing or invalid authentication token.
The caller is not permitted to access this organization or device.
Device, input data stream, or output data stream not found.
The output data stream already has a data source (another analyzer, or a node, subnode, or device).
An upstream service was unreachable or failed.