from typing import Optional

from clarabot_nano.core.state.update.base import AbstractStateUpdateHandler


class SetSolrCore(AbstractStateUpdateHandler):
    HANDLER_KEY = "set_solr_core"

    def get_new_state_kvs(self, data: dict) -> Optional[dict]:
        name = data["name"]
        if name is not None and not isinstance(name, str):
            raise Exception("Invalid solr core")
        return {"solr_core": name}
