| """ |
| Configuration management for ARF Demo |
| """ |
| from pydantic import BaseSettings, Field, validator |
| from typing import Optional, Dict, Any, List |
| from enum import Enum |
| import os |
|
|
|
|
| class ARFMode(str, Enum): |
| """ARF operation modes""" |
| DEMO = "demo" |
| OSS = "oss" |
| ENTERPRISE = "enterprise" |
|
|
|
|
| class SafetyMode(str, Enum): |
| """Safety modes for execution""" |
| ADVISORY = "advisory" |
| APPROVAL = "approval" |
| AUTONOMOUS = "autonomous" |
|
|
|
|
| class Settings(BaseSettings): |
| """ |
| Application settings with environment variable support |
| """ |
| |
| |
| arf_mode: ARFMode = Field( |
| default=ARFMode.DEMO, |
| description="ARF operation mode" |
| ) |
| |
| use_mock_arf: bool = Field( |
| default=True, |
| description="Use mock ARF implementation (for demo mode)" |
| ) |
| |
| |
| arf_api_key: Optional[str] = Field( |
| default=None, |
| description="ARF API key for real integration" |
| ) |
| |
| arf_base_url: str = Field( |
| default="https://api.arf.dev", |
| description="ARF API base URL" |
| ) |
| |
| |
| engineer_hourly_rate: float = Field( |
| default=150.0, |
| ge=50.0, |
| le=500.0, |
| description="Engineer hourly rate in USD" |
| ) |
| |
| engineer_annual_cost: float = Field( |
| default=125000.0, |
| ge=50000.0, |
| le=250000.0, |
| description="Engineer annual cost in USD" |
| ) |
| |
| default_savings_rate: float = Field( |
| default=0.82, |
| ge=0.5, |
| le=0.95, |
| description="Default savings rate with ARF" |
| ) |
| |
| |
| auto_refresh_seconds: int = Field( |
| default=30, |
| ge=5, |
| le=300, |
| description="Auto-refresh interval in seconds" |
| ) |
| |
| max_history_items: int = Field( |
| default=100, |
| ge=10, |
| le=1000, |
| description="Maximum history items to display" |
| ) |
| |
| |
| default_scenario: str = Field( |
| default="Cache Miss Storm", |
| description="Default incident scenario" |
| ) |
| |
| scenario_config_path: str = Field( |
| default="config/scenarios", |
| description="Path to scenario configuration files" |
| ) |
| |
| |
| default_safety_mode: SafetyMode = Field( |
| default=SafetyMode.ADVISORY, |
| description="Default safety mode" |
| ) |
| |
| require_approval: bool = Field( |
| default=True, |
| description="Require human approval for execution" |
| ) |
| |
| |
| @validator("arf_api_key") |
| def validate_api_key(cls, v: Optional[str], values: Dict[str, Any]) -> Optional[str]: |
| if values.get("arf_mode") == ARFMode.ENTERPRISE and not v: |
| raise ValueError("ARF API key required for Enterprise mode") |
| return v |
| |
| @validator("use_mock_arf") |
| def validate_mock_mode(cls, v: bool, values: Dict[str, Any]) -> bool: |
| if values.get("arf_mode") == ARFMode.DEMO: |
| return True |
| return v |
| |
| class Config: |
| env_file = ".env" |
| env_file_encoding = "utf-8" |
| case_sensitive = False |
| use_enum_values = True |
|
|
|
|
| |
| settings = Settings() |
|
|
|
|
| def get_settings() -> Settings: |
| """Get settings instance (singleton pattern)""" |
| return settings |
|
|
|
|
| def reload_settings() -> Settings: |
| """Reload settings from environment""" |
| global settings |
| settings = Settings() |
| return settings |