feat: Add admin endpoints for manual zone sync trigger
This commit is contained in:
@ -1726,3 +1726,59 @@ async def force_activate_listing(
|
|||||||
"slug": listing.slug,
|
"slug": listing.slug,
|
||||||
"public_url": listing.public_url,
|
"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.",
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user