#!/usr/bin/env python3
"""Cek apakah WP Rocket menyediakan endpoint untuk membersihkan cache lewat REST."""
import json, re, urllib.request

UA = {"User-Agent": "Mozilla/5.0"}
try:
    d = json.loads(urllib.request.urlopen(urllib.request.Request(
        "https://www.theskincodeclinic.com/wp-json/", headers=UA), timeout=60).read())
    ns = d.get("namespaces", [])
    print("namespaces:", [n for n in ns if any(k in n.lower() for k in ("rocket", "cache", "purge", "yoast", "wp/v2"))])
    for n in ns:
        if "rocket" in n.lower() or "cache" in n.lower():
            for r2, info in (d.get("routes") or {}).items():
                if r2.startswith("/" + n):
                    print("  ", r2, list((info.get("endpoints") or [{}])[0].get("methods", [])))
except Exception as e:
    print("gagal:", str(e)[:80])
