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


class EditRequireExplicitPeerTrustHandler(AbstractAdminConfigUpdateServerHandler):
    HANDLER_KEY = AdminEditRequireExplicitPeerTrustRequest.TYPE_KEY

    def _create_config_update_request(self) -> dict:
        return {
            "_handler_key": "require_explicit_peer_trust",
            "require_explicit_peer_trust": self.payload.get(AdminEditRequireExplicitPeerTrustRequest.VALUE),
        }

    def _log_message(self) -> str:
        return (
            f"Update require-explicit-peer-trust policy to "
            f"{self.payload.get(AdminEditRequireExplicitPeerTrustRequest.VALUE)}"
        )
