import abc
import logging

from ..types import Alias

logger = logging.getLogger(__name__)


class ClientAliasAdapter(abc.ABC):
    """
    Abstract base class that defines the required interface
    for any config alias adapter. Each derived class must
    implement these methods for their specific platform.
    """

    def __init__(self, client):
        self.client = client

    @abc.abstractmethod
    def create_alias(self, alias: Alias, apply: bool = True):
        """Create an alias on the firewall."""

    @abc.abstractmethod
    def update_alias(self, alias: Alias, apply: bool = True):
        """Update an existing alias on the firewall."""

    @abc.abstractmethod
    def is_alias_in_use(self, alias_name: str) -> bool:
        """Check if a given alias is currently in use by firewall rules."""

    @abc.abstractmethod
    def delete_alias(self, alias_name: str, apply: bool = True) -> dict:
        """Delete an alias on the firewall, optionally applying changes."""

    @abc.abstractmethod
    def rename_alias(self, alias: Alias, new_name: str, apply: bool = True):
        """Rename an alias on the firewall."""

    @abc.abstractmethod
    def get_all_aliases(self) -> list[Alias]:
        """Retrieve all aliases from the firewall."""

    @abc.abstractmethod
    def apply(self):
        """Apply changes to the firewall."""
