Data publishing
Publish what the driver collected: variables, tables, metrics, configuration backups, and driver parameters.
D.createBackup
Section titled “D.createBackup”Function createBackup
Signature
D.createBackup(configurationBackup)Parameters
configurationBackup· `ConfigurationBackup`- The backup object to be filled in and validated
Returns
ConfigurationBackup
Example
D.success(D.createBackup({ label: 'Running config', running: '<config text>', startup: null}));D.createExternalDevice
Section titled “D.createExternalDevice”Creates an External IP device object
Signature
D.createExternalDevice(deviceHost, [deviceCredentials])Parameters
deviceHost· `string`- The IP or Hostname of the external device
deviceCredentials· `object` · optional- The credentials for the external device
deviceCredentials.username· `string`- The device username
deviceCredentials.password· `string`- The device password
Returns
device— - The External Device object
Example
D.createExternalDevice("1.1.1.1", {"username": "root", "password": D.device.password()})D.createMetric
Section titled “D.createMetric”Creates a custom driver metric to be sent in the D.success callback.
This metric is suited for tracking a single key-value pair, if you want to
track tabular data, use D.createTable instead.
Signature
D.createMetric(metricData)Parameters
metricData· `Object`- The metric data object containing the following properties:
metricData.uid· `string`- The identifier of the metric. Must be Unique. Max 50 characters
cannot be one of the following reserved words: "table", "column", "history" metricData.name· `string`- The Name/Label of the metric. Max 100 characters
metricData.value· `string`- The Value of the metric. Max 500 characters
metricData.unit· `string`- The Unit of measurement of the metric (eg %). Max 10 characters
metricData.valueType· `ValueType`- The value type of the metric (used for display purposes)
metricData.metadata· `MetricMetadata` · optional- The metadata of the metric, can be used to store additional information
Returns
Metric
Example
// returns {"uid": "1a", "unit": "C", "value": 60, "label": "CPU Temperature", "metadata": { "url": "http://example.com/" }}D.createMetric({ uid: '1a', name: 'CPU Temperature', value: 60, unit: 'C', valueType: D.valueType.NUMBER, metadata: { url: 'http://example.com/' } })D.createTable
Section titled “D.createTable”Creates a driver table for variable values visualization in a table format
Signature
D.createTable(label, columnHeaders)Parameters
label· `string`- The Table Label
columnHeaders· `Array.` - The List of column header definitions
Returns
Table— - The Custom Driver Table object
Example
D.createTable("My Table", [{"label": "Column A"}, {"label": "Column B", "unit": "%"}])D.createVariable
Section titled “D.createVariable”Creates a custom driver variable to be sent in the D.success callback.
This variable is suited for tracking a single key-value pair, if you want to
track tabular data, use D.createTable instead.
Signature
D.createVariable(uid, name, value, unit, valueType)Parameters
uid· `string`- The identifier of the variable. Must be Unique. Max 50 characters
cannot be one of the following reserved words: "table", "column", "history" name· `string`- The Name/Label of the variable. Max 100 characters
value· `string`- The Value of the variable. Max 500 characters
unit· `string`- The Unit of measurement of the variable (eg %). Max 10 characters
valueType· `ValueType`- The value type of the variable (used for display purposes)
Returns
Variable
Example
// returns {"uid": "1a", "unit": "C", "value": 60, "label": "CPU Temperature"}D.createVariable('1a', 'CPU Temperature', 60, 'C', D.valueType.NUMBER)D.getParameter
Section titled “D.getParameter”Get a predefined parameter during execution by its name. Returns undefined in case the parameter was not provided to the context.
Signature
D.getParameter(parameterName)Parameters
parameterName· `string`- Name of the parameter to get
Returns
string|number|Object|undefined— - the value associated with the provided parameter name
Example
D.getParameter("name")Table.addMetrics
Section titled “Table.addMetrics”Adds a record with metrics data to the table
Signature
Table.addMetrics(id, metrics)Parameters
id· `string`- The unique identifier for the table record. Added as value for column "ID". Max 50 characters
metrics· `Array.<{value: *, metadata: (MetricMetadata|null)}>`- A list of values (and eventually metadata) to be added in the table for that record
Returns
void
Example
driverTable.addMetrics("myId", [{"value":"val 1", "metadata": {"url": "example.com"}}, {"value": "val 2"}])Table.getResult
Section titled “Table.getResult”Returns the prepared table definition and values in the current driver execution
Signature
Table.getResult()Returns
DriverTableResult
Example
driverTable.getResult()Table.insertRecord
Section titled “Table.insertRecord”Inserts a record inside the Custom Driver table object. The final table and values will be sent to the cloud with the D.success() callback implicitly
Signature
Table.insertRecord(id, values)Parameters
id· `string`- The unique identifier for the table record. Added as value for column "ID". Max 50 characters
values· `Array.` - A list of values to be added in the table for that record
Returns
void
Example
driverTable.insertRecord("myId", ["val 1", "val 2"])Table.upsertRecord
Section titled “Table.upsertRecord”Inserts or Updates a record inside the Custom Driver table object. The final table and values will be sent to the cloud with the D.success() callback implicitly
Signature
Table.upsertRecord(id, values)Parameters
id· `string`- The unique identifier for the table record. Added as value for column "ID". Max 50 characters
values· `Array.` - A list of values to be added in the table for that record
Returns
void
Example
driverTable.upsertRecord("myId", ["val 1", "val 2"])ConfigurationBackup
Section titled “ConfigurationBackup”Custom Driver configuration backup Validated version is returned by D.createBackup, should be passed to D.success()
Type definition
Properties
label· `string`- The name of the backup, default is "Custom Driver Configuration Backup"
running· `string`- The configuration currently running on the device, must be less than 1mb
startup· `string`- The optional configuration which will be active when the device is restarted, must be less than 1mb
ignoredLines· `Array.` - List of regular expressions They are used to decide if a line should be considered when comparing configurations for misalignment. The regex engine directly substitutes the match text with an empty string. Do not pass flags in the regex, the format is not supported.
ConfigurationRestore
Section titled “ConfigurationRestore”Custom Driver configuration restore Configuration backup to restore, should be passed to restore()
Type definition
Properties
content· `string`- Configuration backup to restore
label· `string`- Configuration backup label
timestamp· `string`- Configuration backup timestamp
source· `string`- Configuration backup source ("running" or "startup")
Metric
Section titled “Metric”Custom Driver metric created via D.createMetric
Type definition
Properties
uid· `string`- The identifier of the metric. Must be Unique. Max 50 characters
cannot be one of the following reserved words: "table", "column", "history" name· `string`- The Name/Label of the metric. Max 100 characters
value· `string`- The Value of the metric. Max 500 characters
unit· `string`- The Unit of measurement of the metric (e.g., %). Max 10 characters
valueType· `ValueType`- The type of the metric value (used for visualization purposes).
metadata· `MetricMetadata`- The metadata of the metric. It can be used to store additional information
MetricMetadata
Section titled “MetricMetadata”Custom Driver metric metadata
Type definition
Properties
url· `string`- The URL of the metric. It can be used, for example, to link to a dashboard or external resource. Max 2048 characters
Variable
Section titled “Variable”Custom Driver variable created via D.createVariable
Type definition
Properties
uid· `string`- The identifier of the variable. Must be Unique. Max 50 characters
cannot be one of the following reserved words: "table", "column", "history" name· `string`- The Name/Label of the variable. Max 100 characters
value· `string`- The Value of the variable. Max 500 characters
unit· `string`- The Unit of measurement of the metric (e.g., %). Max 10 characters
valueType· `ValueType`- The type of the variable value (used for visualization purposes).