from abc import ABC, abstractmethod
from typing import Any


class RegistrarBase(ABC):
    """Abstract base class that every registrar integration must implement."""

    def __init__(self, credentials: dict[str, Any]) -> None:
        self.credentials = credentials

    @abstractmethod
    async def list_domains(self) -> list[dict[str, Any]]:
        """Return all domains managed by this account.

        Each dict must contain at minimum:
            domain_name (str)       – fully qualified domain name
            expiry_date (date|None) – expiry date or None if unknown
            auto_renew (bool)       – whether auto-renew is enabled
            status (str)            – 'active' | 'expired' | 'locked' | 'unknown'
            registrar_domain_id (str|None) – opaque ID from the registrar
        """

    @abstractmethod
    async def get_dns_records(self, domain_name: str) -> list[dict[str, Any]]:
        """Return all DNS records for *domain_name*.

        Each dict must contain:
            record_type (str)   – A, AAAA, CNAME, MX, TXT, NS, SOA, …
            name (str)          – host/subdomain part
            value (str)         – record value
            ttl (int|None)      – TTL in seconds
            priority (int|None) – MX priority (None for other types)
        """

    @abstractmethod
    async def test_connection(self) -> bool:
        """Return True if the stored credentials are valid, False otherwise."""
