from clarabot_nano.common.config.extract.admin_password import AdminPasswordExtractedConfig
from clarabot_nano.common.config.extract.data_dir import DataDirExtractedConfig
from clarabot_nano.common.config.extract.secrets import SecretsExtractedConfig
from clarabot_nano.common.config.extract.serves import ServesExtractedConfig


class GatewayConfig(
    ServesExtractedConfig, DataDirExtractedConfig, SecretsExtractedConfig, AdminPasswordExtractedConfig
):
    """
    Configurations relevant to the job of the gateway are extracted from the core-config here.
    NOTE: Extra configs are also selected for the few handlers that run in the gateway.
    """

    def __init__(self, config):
        ServesExtractedConfig.__init__(self, config)
        DataDirExtractedConfig.__init__(self, config)
        SecretsExtractedConfig.__init__(self, config)
        AdminPasswordExtractedConfig.__init__(self, config)
        self.name = config["remote"]["name"]  # str of moderate length
        self.room_blocks = config["remote"]["room_blocks"]

    def _matches(self, other) -> bool:
        return (
            self.name == other.name
            and self.room_blocks == other.room_blocks
            and ServesExtractedConfig._matches(self, other)
            and DataDirExtractedConfig._matches(self, other)
            and SecretsExtractedConfig._matches(self, other)
            and AdminPasswordExtractedConfig._matches(self, other)
        )
