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


class AttachDriveHandler(AbstractAdminConfigUpdateServerHandler):
    HANDLER_KEY = AdminAttachDriveRequest.TYPE_KEY

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

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