From 4c1d7069389f7a10dc4049fde53d103162c03628 Mon Sep 17 00:00:00 2001 From: abdulhade Date: Wed, 26 Feb 2025 00:06:45 +0300 Subject: [PATCH] Added the pools-recreate endpoint, can be used to reset pools after editing connections. --- app/connections.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/connections.py b/app/connections.py index c47c20e..7c11f42 100644 --- a/app/connections.py +++ b/app/connections.py @@ -40,7 +40,9 @@ async def read_connections_endpoint( response_model=Connection, dependencies=[Depends(get_current_user)], ) -async def read_connection_endpoint(connection_id: int, db: AsyncSession = Depends(get_db)): +async def read_connection_endpoint( + connection_id: int, db: AsyncSession = Depends(get_db) +): db_connection = await read_connection(db, connection_id) if db_connection is None: raise HTTPException(status_code=404, detail="Connection not found") @@ -68,8 +70,21 @@ async def update_connection_endpoint( status_code=status.HTTP_204_NO_CONTENT, dependencies=[Depends(get_admin_user)], ) -async def delete_connection_endpoint(connection_id: int, db: AsyncSession = Depends(get_db)): +async def delete_connection_endpoint( + connection_id: int, db: AsyncSession = Depends(get_db) +): db_connection = await delete_connection(db=db, connection_id=connection_id) if db_connection is None: raise HTTPException(status_code=404, detail="Connection not found") return None + + +@router.post( + "/pools-recreate", + status_code=status.HTTP_204_NO_CONTENT, + dependencies=[Depends(get_admin_user)], +) +async def recreate_pools(): + from utils.scripts import pools_creator, pools_destroy + await pools_destroy() + await pools_creator()