]> git.ipfire.org Git - pbs.git/commitdiff
api: Add an endpoint to delete mirrors
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 2 Jul 2025 17:28:51 +0000 (17:28 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 2 Jul 2025 17:28:51 +0000 (17:28 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/api/mirrors.py

index 47f505aaa4256da1add03ebfd90366eaf6919d51..971e5b65b2f7b183b5218e8811fc7bca35e51a7f 100644 (file)
@@ -50,6 +50,18 @@ async def get_mirror(mirror: Mirror = fastapi.Depends(get_mirror_from_path)) ->
 
        return mirror
 
+@router.delete("/{hostname}")
+async def delete_mirror(
+       mirror: Mirror = fastapi.Depends(get_mirror_from_path),
+       current_user: User = fastapi.Depends(auth.get_current_admin),
+) -> fastapi.Response:
+       # Delete the mirror
+       async with backend.db as session:
+               await mirror.delete(deleted_by=current_user)
+
+       # Send 204
+       return fastapi.Response(status_code=204)
+
 @router.post("/{hostname}/check")
 async def check_mirror(
        mirror: Mirror = fastapi.Depends(get_mirror_from_path),