/audit
POST ASYNCInitiates a comprehensive health audit of the entire RAIDA network.
POST /api/v1/audit
Alias: /run-raida-health-check
Description
This endpoint triggers a network-wide audit to check the status, consistency, and health of all 25 RAIDA servers. It does not require any parameters in the request body.
Asynchronous Operation
This is an asynchronous operation. It returns a task ID immediately, and you must poll the /tasks/{id}
endpoint to get the final audit report.
Request Body
This endpoint does not require a request body.
Response (in completed task `data`)
A successfully completed audit task will contain the following report in its `data` field.
onlineinteger
The number of RAIDA servers that are online and passed the audit.
pownstringstring
A 25-character string showing the status of each server (e.g., 'p' for pass).
pownarrayarray
A detailed array of status codes for each of the 25 RAIDA servers.
Examples
JavaScript: Run Audit
const apiHost = 'http://localhost:8006';
async function pollTask(taskId) {
const taskResponse = await fetch(`${apiHost}/api/v1/tasks/${taskId}`);
const taskData = await taskResponse.json();
const task = taskData.payload;
console.log(`Task ${taskId} progress: ${task.progress}% - ${task.message}`);
if (task.status === 'completed') {
console.log(`Task finished successfully!`, task.data);
return true; // Stop polling
} else if (task.status === 'error') {
console.error(`Task failed:`, task.message);
return true; // Stop polling
}
return false; // Continue polling
}
async function runAudit() {
try {
const response = await fetch(`${apiHost}/api/v1/audit`, { method: 'POST' });
const taskInfo = await response.json();
const taskId = taskInfo.payload.id;
console.log(`Audit task created with ID: ${taskId}`);
const pollInterval = setInterval(async () => {
const isDone = await pollTask(taskId);
if (isDone) clearInterval(pollInterval);
}, 2000);
} catch (error) {
console.error('Failed to start audit task:', error);
}
}
runAudit();
cURL: Run Audit
# Step 1: Initiate the audit task
TASK_ID=$(curl -s -X POST "http://localhost:8006/api/v1/audit" | jq -r '.payload.id')
echo "Audit task started with ID: $TASK_ID"
# Step 2: Poll the task endpoint
while true; do
RESPONSE=$(curl -s "http://localhost:8006/api/v1/tasks/$TASK_ID")
STATUS=$(echo $RESPONSE | jq -r '.payload.status')
echo "Polling task.. Status: $STATUS"
if [[ "$STATUS" == "completed" ]] || [[ "$STATUS" == "error" ]]; then
echo "Final Response:"
echo $RESPONSE | jq
break
fi
sleep 2
done
Go: Run Audit
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"time"
)
const apiHost = "http://localhost:8006/api/v1"
type TaskResponse struct {
Payload struct {
ID string `json:"id"`
Status string `json:"status"`
Progress int `json:"progress"`
Message string `json:"message"`
Data interface{} `json:"data"`
} `json:"payload"`
}
func pollTask(taskId string) {
for {
resp, err := http.Get(fmt.Sprintf("%s/tasks/%s", apiHost, taskId))
if err != nil {
log.Printf("Error polling task: %v\n", err)
return
}
var taskResp TaskResponse
json.NewDecoder(resp.Body).Decode(&taskResp)
resp.Body.Close()
fmt.Printf("Polling... Status: %s\n", taskResp.Payload.Status)
if taskResp.Payload.Status == "completed" {
fmt.Printf("Task completed. Result: %+v\n", taskResp.Payload.Data)
return
} else if taskResp.Payload.Status == "error" {
fmt.Printf("Task failed: %s\n", taskResp.Payload.Message)
return
}
time.Sleep(2 * time.Second)
}
}
func runAudit() {
resp, err := http.Post(fmt.Sprintf("%s/audit", apiHost), "application/json", nil)
if err != nil {
log.Fatalf("Failed to start audit task: %v", err)
}
defer resp.Body.Close()
var taskResp TaskResponse
json.NewDecoder(resp.Body).Decode(&taskResp)
fmt.Printf("Audit task created with ID: %s\n", taskResp.Payload.ID)
pollTask(taskResp.Payload.ID)
}
func main() {
runAudit()
}