From b1fd284260a7f43d2a010776f66fa81271aa6533 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 2 Jul 2025 17:24:13 +0000 Subject: [PATCH] api: Create an endpoint to manually trigger a mirror check Signed-off-by: Michael Tremer --- src/api/mirrors.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/api/mirrors.py b/src/api/mirrors.py index 915d01d4..47f505aa 100644 --- a/src/api/mirrors.py +++ b/src/api/mirrors.py @@ -21,9 +21,11 @@ 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) -- 2.47.2