]> git.ipfire.org Git - pbs.git/commitdiff
api: Create an endpoint to manually trigger a mirror check
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 2 Jul 2025 17:24:13 +0000 (17:24 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 2 Jul 2025 17:24:13 +0000 (17:24 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/api/mirrors.py

index 915d01d444d637b9dbf7bf5747a9ccf383cc7775..47f505aaa4256da1add03ebfd90366eaf6919d51 100644 (file)
 import fastapi
 
 from . import apiv1
+from . import auth
 from . import backend
 
 from ..mirrors import Mirror
+from ..users import User
 
 # Create a new router for all endpoints
 router = fastapi.APIRouter(
@@ -48,5 +50,17 @@ async def get_mirror(mirror: Mirror = fastapi.Depends(get_mirror_from_path)) ->
 
        return mirror
 
+@router.post("/{hostname}/check")
+async def check_mirror(
+       mirror: Mirror = fastapi.Depends(get_mirror_from_path),
+       current_user: User = fastapi.Depends(auth.get_current_admin),
+) -> fastapi.Response:
+       # Run a check on the mirror
+       async with backend.db as session:
+               await mirror.check(force=True)
+
+       # Send 204
+       return fastapi.Response(status_code=204)
+
 # Add everything to the APIv1
 apiv1.include_router(router)