docs: describe cluster events

This commit is contained in:
2025-05-17 20:14:28 +02:00
parent e30f167766
commit 956037fc03
2 changed files with 18 additions and 2 deletions

View File

@@ -171,7 +171,7 @@ Following events are implemented:
This example will automatically connect to a WiFi access point with the given SSID and password on the interface "wlan0".
```bash
curl -sSf -X POST "http://rpi-test:8080/network/sta" \
curl -X POST "http://rpi-test:8080/network/sta" \
-H "Content-Type: application/json" \
-H "X-API-Token: 1234567890" \
-d '{
@@ -187,7 +187,7 @@ curl -sSf -X POST "http://rpi-test:8080/network/sta" \
This example will create an access point on the interface "wlan0" with the given SSID and password.
```bash
curl -sSf -X POST "http://rpi-test:8080/network/ap" \
curl -X POST "http://rpi-test:8080/network/ap" \
-H "Content-Type: application/json" \
-H "X-API-Token: 1234567890" \
-d '{
@@ -197,3 +197,15 @@ curl -sSf -X POST "http://rpi-test:8080/network/ap" \
"autoconnect": true
}'
```
### Restart the cluster
This example will restart all nodes in the cluster
```bash
curl -X POST "http://rpi-test:8080/cluster/event" \
-H "accept: application/json" \
-H "X-API-Token: 1234567890" \
-d '{
"name": "restart"
}'
```

View File

@@ -304,6 +304,10 @@ func HandleClusterMembers(w http.ResponseWriter, r *http.Request, agent *cluster
}
func HandleClusterEvent(w http.ResponseWriter, r *http.Request, agent *cluster.Agent) {
if agent == nil {
writeError(w, "cluster agent is not initialized", http.StatusInternalServerError)
return
}
var req clusterEventRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
writeError(w, err.Error(), http.StatusBadRequest)