"""
Test Registry API Models

Pydantic models for API requests and responses.
"""

from typing import Optional, Dict, Any, List
from pydantic import BaseModel


# ==============================================================================
# Test Run Models
# ==============================================================================

class TestRunRequest(BaseModel):
    suite_id: str
    service: Optional[str] = None
    triggered_by: str = "manual"


class TestRunResponse(BaseModel):
    run_id: str
    status: str
    message: str


class RegistryResponse(BaseModel):
    services: List[Dict[str, Any]]
    stats: Dict[str, Any]
    last_updated: str


# ==============================================================================
# Backlog Models
# ==============================================================================

class BacklogStatusUpdate(BaseModel):
    status: str
    notes: Optional[str] = None
    assigned_to: Optional[str] = None


class BacklogPriorityUpdate(BaseModel):
    priority: str


class FixAttempt(BaseModel):
    fix_type: str  # manual, auto_claude, auto_script
    fix_description: str
    commit_hash: Optional[str] = None
    success: bool = False


class ManualBacklogEntry(BaseModel):
    """Manueller Backlog-Eintrag fuer nicht-integrierte Features."""
    test_name: str
    service: str
    error_message: str
    priority: str = "medium"  # critical, high, medium, low
    fix_suggestion: Optional[str] = None


# ==============================================================================
# CI/CD Models
# ==============================================================================

class CIResultRequest(BaseModel):
    """Daten von der CI/CD-Pipeline (Woodpecker)"""
    pipeline_id: str
    commit: str
    branch: str
    status: str  # "completed", "failed", "success"
    test_results: Optional[Dict[str, Any]] = None  # Detaillierte Ergebnisse
