"""Environment settings for Flight Booking Agent."""

import logging
import os

# Configure logging with basicConfig
logging.basicConfig(
    level=logging.INFO,  # Set the log level to INFO
    # Define log message format
    format="%(asctime)s,p%(process)s,{%(filename)s:%(lineno)d},%(levelname)s,%(message)s",
)
logger = logging.getLogger(__name__)


class EnvSettings:
    """Environment settings configuration."""

    def __init__(self) -> None:
        """Initialize environment settings."""
        self.db_path: str = os.getenv("DB_PATH", "/app/data/bookings.db")
        self.aws_region: str = os.getenv("AWS_REGION") or os.getenv(
            "AWS_DEFAULT_REGION", "us-east-1"
        )
        self.agent_name: str = os.getenv("AGENT_NAME", "flight-booking")
        self.agent_version: str = os.getenv("AGENT_VERSION", "1.0.0")

        # MCP Gateway Registry URL (TODO: replace later)
        self.mcp_registry_url: str = os.getenv("MCP_REGISTRY_URL", "http://localhost:7860")

        # Agent's public URL (AgentCore Runtime injects automatically)
        self.agent_url: str = os.getenv("AGENTCORE_RUNTIME_URL", "http://127.0.0.1:9000/")

        # Server configuration (fixed for A2A protocol)
        # Agent binds to 0.0.0.0 for container/K8s deployment where network isolation
        # is provided by container runtime. In production, use firewall rules.
        self.host: str = os.getenv("AGENT_HOST", "0.0.0.0")  # nosec B104 - intentional for containerized agent deployment
        self.port: int = 9000

        logger.info(
            f"EnvSettings initialized: agent_name={self.agent_name}, version={self.agent_version}"
        )
        logger.debug(f"Database path: {self.db_path}")
        logger.debug(f"Agent URL: {self.agent_url}")
