import logging

from gateway_core.application.orchestrators.RebootOrchestrator import RebootOrchestrator
from gateway_core.application.ports.NotificationPort import NotificationPort
from gateway_core.domain.Reboot import RebootDto
from gateway_core.domain.errors import NotSupportedError

logger = logging.getLogger(__name__)


class RebootUseCase:
    def __init__(self, orchestrator: RebootOrchestrator, notifier: NotificationPort) -> None:
        self._orchestrator = orchestrator
        self._notifier = notifier

    async def execute(self, dto: RebootDto) -> None:
        logger.info("RebootUseCase: received reboot request %s", dto)

        await self._notifier.notifyRebootStatus(dto, status="Accepted")

        await self._orchestrator.reboot(dto=dto)

        await self._notifier.notifyRebootStatus(dto, status="Triggered")