"""Quick Cloudflare API reachability check (no secrets printed).""" from __future__ import annotations import os import urllib.error import urllib.request def main() -> int: email = os.environ.get("CLOUDFLARE_EMAIL") or os.environ.get( "KEYZOO_ASSET_META_USERNAME" ) key = os.environ.get("CLOUDFLARE_API_KEY") or os.environ.get( "KEYZOO_ASSET_SECRET_GLOBAL_API_KEY" ) if not email or not key: print("missing credentials") return 2 req = urllib.request.Request( "https://api.cloudflare.com/client/v4/user", headers={"X-Auth-Email": email, "X-Auth-Key": key}, ) try: with urllib.request.urlopen(req, timeout=30) as resp: print(f"ok status={resp.status}") return 0 except urllib.error.HTTPError as e: print(f"http {e.code}") return 1 except Exception as e: print(f"{type(e).__name__}: {e}") return 1 if __name__ == "__main__": raise SystemExit(main())