From: Michael Tremer Date: Wed, 2 Jul 2025 17:36:57 +0000 (+0000) Subject: api: Add an endpoint to edit a mirror X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=265e85ca59709c9f1fc33131fa82ecfb00b2a866;p=pbs.git api: Add an endpoint to edit a mirror Signed-off-by: Michael Tremer --- diff --git a/src/api/mirrors.py b/src/api/mirrors.py index 971e5b65..978db93d 100644 --- a/src/api/mirrors.py +++ b/src/api/mirrors.py @@ -19,6 +19,7 @@ ############################################################################### import fastapi +import pydantic from . import apiv1 from . import auth @@ -50,6 +51,31 @@ async def get_mirror(mirror: Mirror = fastapi.Depends(get_mirror_from_path)) -> return mirror +class EditMirrorRequest(pydantic.BaseModel): + # Owner + owner: str = "" + + # Contact + contact: str = "" + + # Notes + notes: str = "" + +@router.put("/{hostname}") +async def edit_mirror( + request: EditMirrorRequest, + mirror: Mirror = fastapi.Depends(get_mirror_from_path), + current_user: User = fastapi.Depends(auth.get_current_admin), +) -> Mirror: + # Update some fields + async with backend.db as session: + mirror.owner = request.owner + mirror.contact = request.contact + mirror.notes = request.notes + + # Return the changed mirror + return mirror + @router.delete("/{hostname}") async def delete_mirror( mirror: Mirror = fastapi.Depends(get_mirror_from_path),