# [DEF:ConfigModels:Module]
# @SEMANTICS: config, models, pydantic
# @PURPOSE: Defines the data models for application configuration using Pydantic.
# @LAYER: Core
# @RELATION: READS_FROM -> config.json
# @RELATION: USED_BY -> ConfigManager

from pydantic import BaseModel, Field
from typing import List, Optional
from ..models.storage import StorageConfig

# [DEF:Schedule:DataClass]
# @PURPOSE: Represents a backup schedule configuration.
class Schedule(BaseModel):
    enabled: bool = False
    cron_expression: str = "0 0 * * *"  # Default: daily at midnight
# [/DEF:Schedule:DataClass]

# [DEF:Environment:DataClass]
# @PURPOSE: Represents a Superset environment configuration.
class Environment(BaseModel):
    id: str
    name: str
    url: str
    username: str
    password: str  # Will be masked in UI
    verify_ssl: bool = True
    timeout: int = 30
    is_default: bool = False
    backup_schedule: Schedule = Field(default_factory=Schedule)
# [/DEF:Environment:DataClass]

# [DEF:LoggingConfig:DataClass]
# @PURPOSE: Defines the configuration for the application's logging system.
class LoggingConfig(BaseModel):
    level: str = "INFO"
    file_path: Optional[str] = "logs/app.log"
    max_bytes: int = 10 * 1024 * 1024
    backup_count: int = 5
    enable_belief_state: bool = True
# [/DEF:LoggingConfig:DataClass]

# [DEF:GlobalSettings:DataClass]
# @PURPOSE: Represents global application settings.
class GlobalSettings(BaseModel):
    storage: StorageConfig = Field(default_factory=StorageConfig)
    default_environment_id: Optional[str] = None
    logging: LoggingConfig = Field(default_factory=LoggingConfig)
    
    # Task retention settings
    task_retention_days: int = 30
    task_retention_limit: int = 100
    pagination_limit: int = 10
# [/DEF:GlobalSettings:DataClass]

# [DEF:AppConfig:DataClass]
# @PURPOSE: The root configuration model containing all application settings.
class AppConfig(BaseModel):
    environments: List[Environment] = []
    settings: GlobalSettings
# [/DEF:AppConfig:DataClass]

# [/DEF:ConfigModels:Module]
