Skip to content

Commit

Permalink
Add integrations docs
Browse files Browse the repository at this point in the history
  • Loading branch information
niondir committed Sep 20, 2024
1 parent b74c17a commit ff78d1a
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 9 deletions.
25 changes: 25 additions & 0 deletions docs/platform/integrations/http.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
draft: true
---

# HTTP forwarding

:::info
Navigate to: Integrations -> HTTP
:::

Forward data from the Lobaro Platform to any HTTP(s) endpoint.

- **HTTP Method:** The HTTP method to use for the request.
- **Target URL:** Any reachable HTTP server endpoint. (Can use Variable Substitution, for details see below.)
- **Authentication:** One of the following authentication schemes can be used:
- **Basic Auth:** Adds Username & password to request headers.
- **Bearer Token:** Adds a Bearer Token to request headers. Just put the Token (without Bearer prefix).
- **OAuth:** Fetch a OAuth token with the given scope from a Token URL using a ClientId and Secret as BasicAuth credentials. The fetched token is used for all API calls and automatically refreshed when invalid.
- **Headers:** List of headers to be set on HTTP request in the format: `<FieldName>: <Value>` (e.g. `Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==`)


:::info[Request logging]
At the lower end of the page you can see the last request and potential errors.
Please note, that we do not update on every request for performance reasons.
:::
Binary file added docs/platform/integrations/img/nav-REST-api.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 14 additions & 6 deletions docs/platform/integrations/index.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
---
title: Integrations (TODO)
title: Integrations
sidebar_position: 0
#displayed_sidebar: cloudSidebar
draft: false
---

# Integrations

:::warning[Work in progress]
This page is not ready yet
:::
![nav-integrations.png](img/nav-integrations.png)


Integrations allows to exchange data between the Lobaro Platform and other applications.

Available integrations are:
- [REST Api](restapi.md)
- [LoRaWAN Network Server Integration](lorawan.md)
- [MQTT](mqtt.md)
- [HTTP forwarding](http.md)





**TODO:**
* LoRaWAN Server Integration (Chripstack)
2 changes: 1 addition & 1 deletion docs/platform/integrations/lorawan.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ title: LoRaWAN LNS (TODO)
draft: true
---

# Integrate LoRaWAN Network Server
# LoRaWAN Network Server Integration
98 changes: 97 additions & 1 deletion docs/platform/integrations/restapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,100 @@
draft: true
---

# REST API (TODO)
# REST API

![nav-REST-api.png](img/nav-REST-api.png)

## Navigation

- Go to: [Integrations -> REST](https://platform.lobaro.com/#/organisation/integrations/rest/)
- Swagger API documentation: [https://platform.lobaro.com/api](https://platform.lobaro.com/api)

### Access Tokens

All API calls must be authenticated with an access token. Access tokens can be managed on the **REST Integration** page.

Each token has a list of roles assigned to it.

#### Token Roles:

- **network-server**: Allows writing device data. Required for LoRaWAN Network Server integrations.

Include the token in the HTTP request header as follows:

- **Field**: `Authorization`
- **Value**: `Bearer eyJhbGciOiJIU...`

### Pagination

Pagination is required to query large datasets.

| Query Parameter | Default | Maximum Value | Description |
|-----------------|---------|---------------|------------------------------------------|
| `limit` | 100 | 10,000 | Maximum number of records to retrieve. |
| `offset` | 0 | N/A | Offset for the first record to retrieve. |

To fetch all data from an endpoint, adjust the offset:

- `?limit=100&offset=0`
- `?limit=100&offset=100`
- Continue increasing the offset by the limit until the number of returned rows is less than the limit.

### Filter Query Parameters

Filters can be added to requests in the form of `<type>:<field>=<op>:<value>`, e.g., `f:createdAt=gt:<timestamp>` to
filter by creation date.

- `<type>`: "f" for fields, or "fa" for arrays (e.g., to search in tags).
- `<field>`: The field being queried (e.g., "id", "createdAt", "updatedAt").
- `<op>`: Operator, see below for allowed operators.
- `<value>`: URL-encoded query value (e.g., `gt:2000-01-01T02:37:00%2B01:00`).

#### Allowed Operators:

| Operator | Meaning | Valid for |
|---------------|----------------------------------------------------------------------|------------|
| `eq` | `=` (equals) | `f` |
| `lte` | `<=` (less than or equal) | `f` |
| `lt` | `<` (less than) | `f` |
| `gte` | `>=` (greater than or equal) | `f` |
| `gt` | `>` (greater than) | `f` |
| `like` | SQL `LIKE` operator | `f` |
| `ilike` | SQL `ILIKE` operator (case-insensitive LIKE) | `f` |
| `isnull` | SQL `is (not) null`. Values: "true" (is null), "false" (is not null) | `f` / `fa` |
| `contains` | Array field contains all specified values | `fa` |
| `containedby` | Array field is contained by the specified list of values | `fa` |
| `overlap` | Array field and list of values overlap | `fa` |

_Default operator: `eq` for fields and `contains` for arrays._

#### Examples:

1. Query JSON field `data.mbus.Id` for a number:
- `&f:data.mbus.Id=eq:130567728`
2. Query JSON field `data.mbus.IdString` for a string:
- `&f:data.mbus.IdString=eq:"10130567728"`

For date ranges, apply the same filter multiple times with different operators:

- `&f:receivedAt=gt:2000-01-01T02:37:00%2B01:00&f:createdAt=lt:2000-01-02T02:37:00%2B01:00`

### Usage Recommendations:

- Set the gzip encoding header to reduce network traffic.
- Use pagination with page sizes smaller than 10,000 entries.
- Prefer `receivedAt` over `createdAt` for time-based queries.

## Example Requests

### Get Data from a Single Device by Address or Tag

Find relevant device(s):

- **By Address**:
`https://platform.lobaro.com/api/devices?limit=100&offset=0&f:addr=eq:352656100677000`
- **By Tag**:
`https://platform.lobaro.com/api/devices?limit=100&offset=0&fa:tags=contains:my-tag,another-tag`

Use the `data.id` field from the first query to fetch device data. Replace `{deviceId}` with the actual device ID:
- `https://platform.lobaro.com/api/devices/{deviceId}/parsed-data?limit=100&offset=0&f:createdAt=gt:2000-01-01T02:37:00%2B01:00`
38 changes: 37 additions & 1 deletion docs/platform/integrations/sftp.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,40 @@
draft: true
---

# SFTP (CSV) Integration (TODO)
# SFTP (CSV) Integration

The SFTP integration allows exporting device data as CSV files over the SFTP protocol at configurable time intervals.
This feature enables seamless data transfer to external servers for processing, storage, or analysis.

## How It Works

- **CSV Export Format**: The integration uses the CSV format specified in the *DeviceTypes TableConfig* to determine the columns included in the export. For more information on how to configure the table, refer to the [Table Config Documentation](../device-types/table-config.md).
- **File Naming Convention**: Each export generates a CSV file for each DeviceType, following the naming convention `<exportTime>_<DeviceType>.csv`.
- For example: `2021-02-18_15-31_Lobaro-NB-IoT-wMBus-Gateway.csv`.
- **Scheduled Exports**: The export process runs at the time schedule you configure.
It automatically gathers data from all devices matching the specified filter and includes any data added since the last successful export.

### Configuration parameters

| Config Param | Examples | Comment |
|------------------------|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Target Host/IP Address | example.com, 127.0.0.1 | Domain or IP Address for your SFTP Server |
| Port | 22 | Port your server uses. Default for SFTP is 22. |
| Path on Server | uploads/lobaro | Directory path to use on the server. The CSV files will be placed into this directory. If the directory doesn't exist and the user has create rights, it will be created. |
| Username | foobar | Username to log in with. Make sure the user has permission to write into the target directory. |
| Password | MySecretPassword2Use | Password for the user. |
| Filter | NB-IoT-Gateway-Filter | Filter to use for the integration (defined under Integration → Filter). Only devices matching the filter will be exported. |
| Time to run | 04:30 | Time to execute the integration daily. |


## Key Features

- **Configurable Time Intervals**: You can specify the exact time when the CSV export should occur, ensuring the process fits within your data processing or reporting workflows.
- **Per-DeviceType CSV Files**: To keep data organized, a separate CSV file is generated for each device type, making it easier to manage and analyze specific device data.
- **Incremental Data Export**: Only data that has changed or been added since the last export is included, ensuring that the export is efficient and prevents redundant data transfer.

## Example

If the integration is configured to run at 04:30 daily, and the DeviceType is "Lobaro-NB-IoT-wMBus-Gateway," the export file generated on February 18, 2021, at 15:31 will be named:
`2021-02-18_15-31_Lobaro-NB-IoT-wMBus-Gateway.csv`.

0 comments on commit ff78d1a

Please sign in to comment.