from clarabot_nano.common.request.server_general import AdminDetachDriveRequest
from clarabot_nano.server.general.handler.admin.config_update.base import AbstractAdminConfigUpdateServerHandler


class DetachDriveHandler(AbstractAdminConfigUpdateServerHandler):
    HANDLER_KEY = AdminDetachDriveRequest.TYPE_KEY

    def _create_config_update_request(self) -> dict:
        return {
            "_handler_key": "drive:detach-room",
            "path": self.payload.get(AdminDetachDriveRequest.PATH),
            "room_id": self.payload.get(AdminDetachDriveRequest.TARGET_ROOM_ID),
        }

    def _log_message(self) -> str:
        return (
            f"Room {self.payload.get(AdminDetachDriveRequest.TARGET_ROOM_ID)} "
            f"detached to Nano drive at {self.payload.get(AdminDetachDriveRequest.PATH)}"
        )
