diff --git a/docs/api.txt b/docs/api.txt new file mode 100644 index 0000000..c6b5ead --- /dev/null +++ b/docs/api.txt @@ -0,0 +1,64 @@ +API Endpoints: + +1. GET /info + - Returns current system info and thresholds. + - Response: { + uptime: datetime, + cpu: float, + ram: float, + disk: float, + cpu_threshold: int, + ram_threshold: int, + disk_threshold: int, + cpu_normal: bool, + ram_normal: bool, + disk_normal: bool + } + +2. GET /limits + - Returns current threshold limits. + - Response: { + cpu_threshold: int, + ram_threshold: int, + disk_threshold: int + } + +3. POST /limits + - Sets new threshold limits. + - Body: { + cpu_threshold: int, + ram_threshold: int, + disk_threshold: int + } + - Response: { + cpu: int, + ram: int, + disk: int + } + +4. GET /overages + - Returns a list of overage events. + - Response: [ + { + id: int, + cpu_overage: int, + ram_overage: int, + disk_overage: int, + timestamp: datetime + }, + ... + ] + +5. GET /overages/{overage_id} + - Returns a specific overage event by ID. + - Response: { + id: int, + cpu_overage: int, + ram_overage: int, + disk_overage: int, + timestamp: datetime + } + +6. DELETE /overages/{overage_id} + - Deletes a specific overage event by ID. + - Response: { detail: "Overage event deleted" } diff --git a/main.py b/main.py index 47e6549..be9fee6 100644 --- a/main.py +++ b/main.py @@ -227,4 +227,74 @@ app.add_middleware( allow_headers=["*"], ) -app.mount("/", StaticFiles(directory="./webroot", html=True), name="static") \ No newline at end of file +app.mount("/", StaticFiles(directory="./webroot", html=True), name="static") + + + +# API DOCS: + """ + API Endpoints: + + 1. GET /info + - Returns current system info and thresholds. + - Response: { + uptime: datetime, + cpu: float, + ram: float, + disk: float, + cpu_threshold: int, + ram_threshold: int, + disk_threshold: int, + cpu_normal: bool, + ram_normal: bool, + disk_normal: bool + } + + 2. GET /limits + - Returns current threshold limits. + - Response: { + cpu_threshold: int, + ram_threshold: int, + disk_threshold: int + } + + 3. POST /limits + - Sets new threshold limits. + - Body: { + cpu_threshold: int, + ram_threshold: int, + disk_threshold: int + } + - Response: { + cpu: int, + ram: int, + disk: int + } + + 4. GET /overages + - Returns a list of overage events. + - Response: [ + { + id: int, + cpu_overage: int, + ram_overage: int, + disk_overage: int, + timestamp: datetime + }, + ... + ] + + 5. GET /overages/{overage_id} + - Returns a specific overage event by ID. + - Response: { + id: int, + cpu_overage: int, + ram_overage: int, + disk_overage: int, + timestamp: datetime + } + + 6. DELETE /overages/{overage_id} + - Deletes a specific overage event by ID. + - Response: { detail: "Overage event deleted" } + """ \ No newline at end of file