api docs
This commit is contained in:
64
docs/api.txt
Normal file
64
docs/api.txt
Normal file
@@ -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" }
|
||||
72
main.py
72
main.py
@@ -227,4 +227,74 @@ app.add_middleware(
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
app.mount("/", StaticFiles(directory="./webroot", html=True), name="static")
|
||||
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" }
|
||||
"""
|
||||
Reference in New Issue
Block a user