FastAPI-based SSL certificate automation server. - Google Public CA wildcard cert issuance via certbot - Cloudflare DNS-01 challenge with auto EAB key generation - APISIX multi-instance deployment with domain-instance mapping - Vault integration for all secrets - Bearer token auth, retry logic, Discord DM alerts - Auto-renewal scheduler (daily 03:00 UTC) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
import httpx
|
|
|
|
from .config import AppConfig
|
|
|
|
|
|
async def list_domains(config: AppConfig) -> list[dict]:
|
|
"""Cloudflare API로 zone 목록 조회."""
|
|
headers = {
|
|
"Authorization": f"Bearer {config.cloudflare_api_token}",
|
|
"Content-Type": "application/json",
|
|
}
|
|
zones = []
|
|
page = 1
|
|
|
|
async with httpx.AsyncClient(timeout=30) as client:
|
|
while True:
|
|
resp = await client.get(
|
|
"https://api.cloudflare.com/client/v4/zones",
|
|
headers=headers,
|
|
params={"page": page, "per_page": 50},
|
|
)
|
|
resp.raise_for_status()
|
|
data = resp.json()
|
|
|
|
for zone in data["result"]:
|
|
zones.append({
|
|
"id": zone["id"],
|
|
"name": zone["name"],
|
|
"status": zone["status"],
|
|
})
|
|
|
|
info = data.get("result_info", {})
|
|
if page >= info.get("total_pages", 1):
|
|
break
|
|
page += 1
|
|
|
|
return zones
|