initial - add implementation for simple crowdsec app to list and delete non-CAPI decisions
This commit is contained in:
commit
9aaf3d32d0
7 changed files with 349 additions and 0 deletions
22
app/api.py
Normal file
22
app/api.py
Normal 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))
|
||||
Loading…
Add table
Add a link
Reference in a new issue