from typing import Dict
from typing import Any


def _make_pod_envconfig(
    config: Dict[str, Any], relation_state: Dict[str, Any]
) -> Dict[str, Any]:
    """Generate pod environment configuration.

    Args:
        config (Dict[str, Any]): configuration information.
        relation_state (Dict[str, Any]): relation state information.

    Returns:
        Dict[str, Any]: pod environment configuration.
    """
    envconfig = {
        # General configuration
        "ALLOW_ANONYMOUS_LOGIN": "yes",
        "OSMMON_OPENSTACK_DEFAULT_GRANULARITY": config["openstack_default_granularity"],
        "OSMMON_GLOBAL_REQUEST_TIMEOUT": config["global_request_timeout"],
        "OSMMON_GLOBAL_LOGLEVEL": config["log_level"],
        "OSMMON_COLLECTOR_INTERVAL": config["collector_interval"],
        "OSMMON_EVALUATOR_INTERVAL": config["evaluator_interval"],
        # Kafka configuration
        "OSMMON_MESSAGE_DRIVER": "kafka",
        "OSMMON_MESSAGE_HOST": relation_state["message_host"],
        "OSMMON_MESSAGE_PORT": relation_state["message_port"],
        # Database configuration
        "OSMMON_DATABASE_DRIVER": "mongo",
        "OSMMON_DATABASE_URI": relation_state["database_uri"],
        "OSMMON_DATABASE_COMMONKEY": config["database_commonkey"],
        # Prometheus configuration
        "OSMMON_PROMETHEUS_URL": f"http://{relation_state['prometheus_host']}:{relation_state['prometheus_port']}",
        # VCA configuration
        "OSMMON_VCA_HOST": config["vca_host"],
        "OSMMON_VCA_USER": config["vca_user"],
        "OSMMON_VCA_SECRET": config["vca_password"],
        "OSMMON_VCA_CACERT": config["vca_cacert"],
    }

    return envconfig