From 304dd51ef084d3e40bc9f72f7f0fadfe4c8ca29f Mon Sep 17 00:00:00 2001 From: Iam54r1n4 Date: Sat, 8 Feb 2025 01:06:43 +0000 Subject: [PATCH] Refactor ip APIs --- .../webpanel/routers/api/v1/config/ip.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/core/scripts/webpanel/routers/api/v1/config/ip.py b/core/scripts/webpanel/routers/api/v1/config/ip.py index 0e56cbb..170ecd2 100644 --- a/core/scripts/webpanel/routers/api/v1/config/ip.py +++ b/core/scripts/webpanel/routers/api/v1/config/ip.py @@ -10,6 +10,15 @@ router = APIRouter() @router.get('/add') async def add_ip_api(): + """ + Adds the auto-detected IP addresses to the .configs.env file. + + Returns: + A DetailResponse with a message indicating the IP addresses were added successfully. + + Raises: + HTTPException: if an error occurs while adding the IP addresses. + """ try: cli_api.add_ip_address() return DetailResponse(detail='IP addresses added successfully.') @@ -19,6 +28,18 @@ async def add_ip_api(): @router.post('/edit', response_model=DetailResponse) async def edit_ip_api(body: EditInputBody): + """ + Edits the IP addresses in the .configs.env file. + + Args: + body: An instance of EditInputBody containing the new IPv4 and/or IPv6 addresses. + + Returns: + A DetailResponse with a message indicating the IP addresses were edited successfully. + + Raises: + HTTPException: if an error occurs while editing the IP addresses. + """ try: if not body.ipv4 and not body.ipv6: raise HTTPException(status_code=400, detail='Error: You must specify either ipv4 or ipv6')