Added the pools-recreate endpoint, can be used to reset pools after editing connections.

This commit is contained in:
2025-02-26 00:06:45 +03:00
parent 02567550ac
commit 4c1d706938

View File

@@ -40,7 +40,9 @@ async def read_connections_endpoint(
response_model=Connection, response_model=Connection,
dependencies=[Depends(get_current_user)], 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) db_connection = await read_connection(db, connection_id)
if db_connection is None: if db_connection is None:
raise HTTPException(status_code=404, detail="Connection not found") 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, status_code=status.HTTP_204_NO_CONTENT,
dependencies=[Depends(get_admin_user)], 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) db_connection = await delete_connection(db=db, connection_id=connection_id)
if db_connection is None: if db_connection is None:
raise HTTPException(status_code=404, detail="Connection not found") raise HTTPException(status_code=404, detail="Connection not found")
return None 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()