A web server that receives messages forwarded by devices and stores them in a database. This service is currently being rewritten in golang to become suitable for running on constrained boards.
PATH environment variable:export PATH=$PATH:<your_go_workspace>/bin
You can set the ENV environment variable to development and update the internal/config/development.yaml when necessary. On the other way, you can use environment variables to configure your installation. In case you are running the published Docker image, you'll need to stick with the environment variables.
The configuration parameters are the following (the environment variable name is in parenthesis):
server
port (SERVER_PORT) Number Server port number. (Default: 80)make tools
make run
You can use the
make watchcommand to run the application on watching mode, allowing it to be restarted automatically when the code changes.
Make sure you have Docker Engine installed.
A container is specified at docker/Dockerfile. To use it, execute the following steps:
Build the image:
docker build . -f docker/Dockerfile -t cesarbr/knot-cloud-storage
Create a file containing the configuration as environment variables.
Run the container:
docker run --env-file knot-cloud-storage.env -ti cesarbr/knot-cloud-storage
A development container is specified at docker/Dockerfile-dev. To use it, execute the following steps:
Build the image:
docker build . -f docker/Dockerfile-dev -t cesarbr/knot-cloud-storage:dev
Create a file containing the configuration as environment variables.
Run the container:
docker run --env-file knot-cloud-storage.env -p 8080:80 -v `pwd`:/usr/src/app -ti cesarbr/knot-cloud-storage:dev
The first argument to -v must be the root of this repository, so if you are running from another folder, replace pwd with the corresponding path.
This will start the server with auto-reload.
curl http://<hostname>:<port>/healthcheck
POST /data
Stores the device messages.
| Field | Required | Description |
|---|---|---|
| auth_token | Y | User's authentication token |
| Field | Required | Description |
|---|---|---|
| data | Y | The message data sent by the device. It includes both sender identification and payload. |
POST https://storage.knot.cloud/data
{
"from": "188824f0-28c4-475b-ab36-2505402bebcb",
"payload": {
"sensor_id": 2,
"value": 234
}
}
201 Created
GET /data
Get all the device messages.
In order to get the device messages, you need to be authenticated as its owner.
| Field | Required | Description |
|---|---|---|
| auth_token | Y | User's authentication token |
| Field | Required | Description |
|---|---|---|
| order | N | Ascending (1) or descending (-1) order, default=1. |
| skip | N | The number of data to skip (returns skip + 1), default=0. |
| take | N | The maximum number of data that you want from skip + 1 (the number is limited to 100), default=10. |
| startDate | N | The start date that you want your set of data (format=YYYY-MM-DD HH:MM:SS). |
| finishDate | N | The finish date that you want your set of data (format=YYYY-MM-DD HH:MM:SS). |
GET https://storage.knot.cloud/data?take=15&order=1
[
{
"from": "188824f0-28c4-475b-ab36-2505402bebcb",
"payload": {
"sensorId": 2,
"value": 234
},
"timestamp": "2020-04-10T10:32:26.456753-03:00"
},
{
"from": "188824f0-28c4-475b-ab36-2505402bebcb",
"payload": {
"sensorId": 1,
"value": true
},
"timestamp": "2020-04-13T13:56:23.596301-03:00"
}
]
GET /data/{deviceID}
Get the messages by a specific device.
In order to get the device messages, you need to be authenticated as its owner.
| Field | Required | Description |
|---|---|---|
| auth_token | Y | User's authentication token |
| Field | Required | Description |
|---|---|---|
| order | N | Ascending (1) or descending (-1) order, default=1. |
| skip | N | The number of data to skip (returns skip + 1), default=0. |
| take | N | The maximum number of data that you want from skip + 1 (the number is limited to 100), default=10. |
| startDate | N | The start date that you want your set of data (format=YYYY-MM-DD HH:MM:SS). |
| finishDate | N | The finish date that you want your set of data (format=YYYY-MM-DD HH:MM:SS). |
GET https://storage.knot.cloud/data/cc5429a29afcd158?startDate=2020-04-13 13:00:00
[
{
"from": "188824f0-28c4-475b-ab36-2505402bebcb",
"payload": {
"sensorId": 1,
"value": true
},
"timestamp": "2020-04-13T13:56:23.596301-03:00"
}
]
GET /data/{deviceID}/sensor/{sensorID}
Get the messages by a specific device sensor.
In order to get the device messages, you need to be authenticated as its owner.
| Field | Required | Description |
|---|---|---|
| auth_token | Y | User's authentication token |
| Field | Required | Description |
|---|---|---|
| order | N | Ascending (1) or descending (-1) order, default=1. |
| skip | N | The number of data to skip (returns skip + 1), default=0. |
| take | N | The maximum number of data that you want from skip + 1 (the number is limited to 100), default=10. |
| startDate | N | The start date that you want your set of data (format=YYYY-MM-DD HH:MM:SS). |
| finishDate | N | The finish date that you want your set of data (format=YYYY-MM-DD HH:MM:SS). |
GET https://storage.knot.cloud/data/cc5429a29afcd158/sensor/2
[
{
"from": "188824f0-28c4-475b-ab36-2505402bebcb",
"payload": {
"sensorId": 2,
"value": 234
},
"timestamp": "2020-04-10T10:32:26.456753-03:00"
}
]
DELETE /data
Delete all the device messages.
In order to delete the messages, you need to be authenticated as a valid user. Only data from the things which are owned by this user will be removed.
| Field | Required | Description |
|---|---|---|
| auth_token | Y | User's authentication token |
DELETE https://storage.knot.cloud/data
200 OK
DELETE /data/{deviceID}
Delete all messages from a specific device.
In order to delete the device messages, you need to be authenticated as its owner.
| Field | Required | Description |
|---|---|---|
| auth_token | Y | User's authentication token |
DELETE https://storage.knot.cloud/data/cc5429a29afcd158
200 OK
Content type
Image
Digest
Size
9.2 MB
Last updated
about 6 years ago
docker pull cesarbr/knot-cloud-storage