from typing import Optional

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


class SetIndexerStatus(AbstractStateUpdateHandler):
    HANDLER_KEY = "set_indexer_status"

    def get_new_state_kvs(self, data: dict) -> Optional[dict]:
        if not isinstance(status := data["status"], str):
            raise Exception("Invalid indexer status")
        return {"indexer_status": status}
