# Package lynx
# Functions
# apiCall
Perform an authenticated call to the API using the gateways credentials. Returning the response as a LUA object.
# Parameters
Name | Optional | Description |
---|---|---|
Method | No | HTTP Method to use |
Path | No | Path of the URL to request |
Body | Yes | Include a body in the request |
IoTCfg | Yes | Config to load parameters and authentication from |
# Example
local res = lynx.apiCall("POST", "/api/v2/functionx/1", {
type = "test",
meta = {key1 = "val1"}
})
# apiCallRaw
Perform a GET request to the API using the gateways or provided credentials. The result is returned as a string if success or error object.
# Parameters
Name | Optional | Description |
---|---|---|
Path | No | Path in the Lynx API to use |
IoTCfg | Yes | Config to load parameters and authentication from |
# Example
local resRaw = lynx.apiCallRaw("/api/vw/functionx/1")
# getFunctions
Fetch a list of functionx objects for the installation using the API.
# Parameters
Name | Optional | Description |
---|---|---|
Filter | Yes | Metadata or type used to filter the functions |
# Example
local functions = lynx.getFunctions({
key1 = "value1",
key2 = "value2"
})
# createFunction
Create a new function in the installation using the API.
# Parameters
Name | Optional | Description |
---|---|---|
fn | No | The complete FunctionX object |
# Example
local fn = {
type = "example",
installation_id = 12,
meta = {
name = "My exmaple",
topic_read = "obj/example/sensor/1/value"
}
}
lynx.createFunction(fn)
# deleteFunction
Delete a function in the installation using the API.
# Parameters
Name | Optional | Description |
---|---|---|
id | No | ID of the function to delete |
# Example
lynx.deleteFunction(7)
# getApps
Performs an API-request and fetches all configured for the current installation.
# Example
local apps = lynx.getApps()
# downloadApp
Performs a file download using the API to fetch the executable code for an app. The app is returned as a text string.
# Parameters
Name | Optional | Description |
---|---|---|
App-ID | Yes | ID of the app to download |
Version | Yes | Version of the app to download |
# Example
local appCode = lynx.downloadApp(1, "0.3.5")
# getStatus
Fetch last know values from the backend. There is a small delay until published values are available.
# Parameters
Name | Optional | Description |
---|
# Example
local statuses = lynx.getStatus()
# getLog
Fetch a log for recorded mqtt values. Usually contains a lot of data.
# Parameters
Name | Optional | Description |
---|---|---|
to | No | Only fetch logs to this time as unix-timestamp |
from | No | Only fetch logs from this time as unix-timestamp |
limit | No | Limit the amount of log rows fetched |
# Example
local logs = lynx.getLog(1603365159, 1603355159, 100)
# getDevices
Fetch a list of DeviceX objects for the installation using the API.
# Parameters
Name | Optional | Description |
---|---|---|
Filter | Yes | Metadata or type used to filter the devices |
# Example
local devices = lynx.getDevices({
key1 = "value1",
key2 = "value2"
})
# createDevice
Create a new DeviceX in the installation using the API.
# Parameters
Name | Optional | Description |
---|---|---|
fn | No | The complete DeviceX object |
# Example
local dev = {
type = "example",
installation_id = 12,
meta = {
name = "A device",
serial = "ABCD1234"
}
}
lynx.createDevice(fn)
# deleteDevice
Delete a device in the installation using the API.
# Parameters
Name | Optional | Description |
---|---|---|
id | No | ID of the device to delete |
# Example
lynx.deleteDevice(7)
# notify(id, body)
Trigger the backend to handle notifications for a specific output using the API.
# Parameters
Name | Optional | Description |
---|---|---|
id | No | ID of the output to trigger |
body | Yes | Payload to include in the request, can be used in templates |
# Example
local myData = {
value = 23.5,
action = "over"
}
lynx.notify(12, myData)