From bbf6afe2f670f965e3e90664035f72773afd8a3d Mon Sep 17 00:00:00 2001 From: Yves Gugger Date: Sun, 21 Dec 2025 12:36:32 +0100 Subject: [PATCH] feat: Add admin endpoints for manual zone sync trigger --- backend/app/api/admin.py | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/backend/app/api/admin.py b/backend/app/api/admin.py index 269061b..848f60d 100644 --- a/backend/app/api/admin.py +++ b/backend/app/api/admin.py @@ -1726,3 +1726,59 @@ async def force_activate_listing( "slug": listing.slug, "public_url": listing.public_url, } + + +# ============== Zone File Sync ============== + +@router.post("/zone-sync/switch") +async def trigger_switch_sync( + background_tasks: BackgroundTasks, + db: Database, + admin: User = Depends(require_admin), +): + """ + Trigger manual Switch.ch zone file sync (.ch, .li). + Admin only. + """ + from app.services.zone_file import ZoneFileService + + async def run_sync(): + zf = ZoneFileService() + from app.database import async_session_maker + async with async_session_maker() as session: + result = await zf.sync_all_zones(session) + return result + + background_tasks.add_task(run_sync) + + return { + "status": "started", + "message": "Switch.ch zone sync started in background. Check logs for progress.", + } + + +@router.post("/zone-sync/czds") +async def trigger_czds_sync( + background_tasks: BackgroundTasks, + db: Database, + admin: User = Depends(require_admin), +): + """ + Trigger manual ICANN CZDS zone file sync (gTLDs). + Admin only. + """ + from app.services.czds_client import CZDSClient + + async def run_sync(): + client = CZDSClient() + from app.database import async_session_maker + async with async_session_maker() as session: + result = await client.sync_all_zones(session) + return result + + background_tasks.add_task(run_sync) + + return { + "status": "started", + "message": "ICANN CZDS zone sync started in background. Check logs for progress.", + }