from clarabot_nano.core.config.update.base import AbstractRemoteConfigUpdateHandler


class UpdateName(AbstractRemoteConfigUpdateHandler):
    HANDLER_KEY = "name"

    def _execute(self, data: dict):
        # NOTE: validation by schema
        self._c["name"] = data["name"]

    def _describe_change(self, old_config: dict, new_config: dict, data: dict) -> str:
        return f"Nano renamed to {new_config.get('name')!r}"
