initial - add implementation for simple crowdsec app to list and delete non-CAPI decisions

This commit is contained in:
Viktor Barzin 2025-10-14 19:21:36 +00:00
commit 9aaf3d32d0
No known key found for this signature in database
GPG key ID: 4056458DBDBF8863
7 changed files with 349 additions and 0 deletions

22
app/api.py Normal file
View file

@ -0,0 +1,22 @@
from fastapi import APIRouter, HTTPException
from app.crowdsec_api import list_decisions, delete_decision
router = APIRouter()
@router.get("/decisions")
async def get_decisions():
try:
decisions = await list_decisions()
return {"decisions": decisions}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@router.delete("/decisions/{ip}")
async def remove_decision(ip: str):
try:
await delete_decision(ip)
return {"status": "deleted", "ip": ip}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))