Files
NetAlertX/docs/API_ONLINEHISTORY.md
jokob-sk df9a17ed85
Some checks failed
Code checks / check-url-paths (push) Has been cancelled
docker / docker_dev (push) Has been cancelled
Deploy MkDocs / deploy (push) Has been cancelled
docs
2025-08-24 12:57:36 +10:00

60 lines
1.3 KiB
Markdown
Executable File

# Online History API Endpoints
Manage the **online history records** of devices. Currently, the API supports deletion of all history entries. All endpoints require **authorization**.
---
## 1. Delete Online History
* **DELETE** `/history`
Remove **all records** from the online history table (`Online_History`). This operation **cannot be undone**.
**Response** (success):
```json
{
"success": true,
"message": "Deleted online history"
}
```
**Error Responses**:
* Unauthorized → HTTP 403
---
### Example `curl` Request
```bash
curl -X DELETE "http://<server_ip>:<GRAPHQL_PORT>/history" \
-H "Authorization: Bearer <API_TOKEN>"
```
---
### Implementation Details
The endpoint calls the helper function `delete_online_history()`:
```python
def delete_online_history():
"""Delete all online history activity"""
conn = get_temp_db_connection()
cur = conn.cursor()
# Remove all entries from Online_History table
cur.execute("DELETE FROM Online_History")
conn.commit()
conn.close()
return jsonify({"success": True, "message": "Deleted online history"})
```
* Opens a temporary database connection for the request.
* Executes a **full table delete** (`DELETE FROM Online_History`).
* Commits the transaction and closes the connection.
* Returns a JSON confirmation message.