Skip to content

Commit 5b6cabd

Browse files
committed
qnap: Add REST API documentation
1 parent 5e6ee8d commit 5b6cabd

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed

clis/teliod/QNAP.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# QNAP Build
2+
3+
To build Teliod package for QNAP devices there are two alternatives:
4+
5+
- Run cargo build directly:
6+
```cargo build --verbose --target x86_64-unknown-linux-musl --package teliod --features qnap```
7+
8+
- Run build script [Recommended]:
9+
```../../ci/build_libtelio.py build qnap x86_64 [--debug]```
10+
11+
The build script has an additional stage at the end of the build where it creates the QNAP package.
12+
13+
## REST API
14+
15+
This REST API allows interaction with the Teliod daemon. It provides endpoints for managing the daemon, updating its configuration, and retrieving logs and status information.
16+
17+
### Endpoints
18+
19+
#### 1. **Start the Daemon**
20+
- **Endpoint**: `/`
21+
- **Method**: `POST`
22+
- **Description**: Starts the Teliod Daemon in the background.
23+
- **Request Body**: None
24+
- **Responses**:
25+
- **200 OK**: Daemon started successfully.
26+
- **400 Bad Request**: Daemon is already running.
27+
- **500 Internal Server Error**: Failed to start the daemon.
28+
29+
#### 2. **Stop the Daemon**
30+
- **Endpoint**: `/`
31+
- **Method**: `DELETE`
32+
- **Description**: Stops the running Teliod Daemon.
33+
- **Request Body**: None
34+
- **Responses**:
35+
- **200 OK**: Daemon stopped successfully.
36+
- **400 Bad Request**: Daemon is not running.
37+
- **500 Internal Server Error**: Failed to stop the daemon.
38+
39+
#### 3. **Update Configuration**
40+
- **Endpoint**: `/`
41+
- **Method**: `PATCH`
42+
- **Description**: Updates the daemon configuration with provided settings.
43+
- **Request Body**: JSON object containing the configuration updates. Only specified fields will be updated; others remain unchanged.
44+
- **Example Request Body**:
45+
```json
46+
{
47+
"log_level": "info",
48+
"log_file_path": "/new/path/to/log.log"
49+
}
50+
```
51+
- **Responses**:
52+
- **200 OK**: Configuration updated successfully
53+
- **400 Bad Request**: Invalid JSON payload or configuration fields.
54+
- **500 Internal Server Error**: Failed to update configuration.
55+
56+
#### 4. **Get Meshnet Status**
57+
- **Endpoint**: `/?info=get-status`
58+
- **Method**: `GET`
59+
- **Description**: Retrieves the current status of the Meshnet from Teliod daemon.
60+
- **Request Body**: None
61+
- **Responses**:
62+
- **200 OK**: Status information in JSON format.
63+
```json
64+
{
65+
"telio_is_running": true,
66+
"meshnet_ip": null,
67+
"external_nodes": []
68+
...
69+
}
70+
```
71+
- **500 Internal Server Error**: Failed to retrieve status.
72+
73+
#### 5. **Get Meshnet Logs**
74+
- **Endpoint**: `/?info=get-meshnet-logs`
75+
- **Method**: `GET`
76+
- **Description**: Retrieves the latest logs of the Meshnet.
77+
- **Request Body**: None
78+
- **Responses**:
79+
- **200 OK**: Log content in JSON format.
80+
```json
81+
{
82+
"Log line 1\nLog line 2\nLog line 3\n..."
83+
}
84+
```
85+
- **404 Not Found**: Log file not found.
86+
87+
#### 6. **Get Teliod Logs**
88+
- **Endpoint**: `/?info=get-teliod-logs`
89+
- **Method**: `GET`
90+
- **Description**: Retrieves the latest logs of the Teliod Daemon.
91+
- **Request Body**: None
92+
- **Responses**:
93+
- **200 OK**: Log content in JSON format.
94+
```json
95+
{
96+
"Log line 1\nLog line 2\nLog line 3\n..."
97+
}
98+
```
99+
- **404 Not Found**: Log file not found.
100+
101+
### Error Handling
102+
103+
For all endpoints, the following error codes may be returned:
104+
- **400 Bad Request**: The request was malformed or invalid.
105+
- **500 Internal Server Error**: An unexpected error occurred while processing the request.
106+
107+
### Example usage with curl
108+
109+
#### Start Teliod daemon:
110+
```bash
111+
curl -X POST http://<NAS-IP>:8080/
112+
```
113+
114+
#### Stop Teliod daemon:
115+
```bash
116+
curl -X POST http://<NAS-IP>:8080/
117+
```
118+
119+
#### Get Meshnet logs:
120+
```bash
121+
curl -X GET "http://<NAS-IP>:8080/?info=get-meshnet-logs"
122+
```
123+
124+
#### Update Config:
125+
```bash
126+
curl -X PATCH -H "Content-Type: application/json" -d '{"log_level":"info", authentication_token": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"}' http://<NAS-IP>:8080/cgi-bin/qpkg/teliod.cgi
127+
```

0 commit comments

Comments
 (0)