from parallels.core.hosting_repository.domain_alias import DomainAliasModel
from parallels.plesk.hosting_repository.domain_alias import PleskDomainAliasModel
from parallels.plesk_multi_server.hosting_repository.base import PleskMultiServerBaseModel


class PleskMultiServerDomainAliasModel(DomainAliasModel, PleskMultiServerBaseModel):
    def get_list(self):
        """Retrieve list of domain aliases in target panel

        :rtype: list[parallels.core.hosting_repository.domain_alias.DomainAliasEntity]
        """
        return PleskDomainAliasModel(self.pms_management_server).get_list()

    def create_from_dump(self, subscription_name, domain_alias_dump, domain_name):
        """Create domain alias in target panel

        :type subscription_name: str
        :type domain_alias_dump: parallels.core.dump.data_model.DomainAlias
        :type domain_name: str
        """
        server = self.get_subscription_service_server(subscription_name)
        return PleskDomainAliasModel(server).create_from_dump(
            subscription_name, domain_alias_dump, domain_name
        )

    def is_exists_by_subscription(self, subscription_name, domain_alias_name):
        """Check if domain alias with given name exists in target panel

        :type subscription_name: str
        :type domain_alias_name: str
        :rtype: bool
        """
        server = self.get_subscription_service_server(subscription_name)
        return PleskDomainAliasModel(server).is_exists_by_subscription(subscription_name, domain_alias_name)
