"""
Evidence Pydantic schemas — extracted from compliance/api/schemas.py.

Phase 1 Step 3: the monolithic ``compliance.api.schemas`` module is being
split per domain under ``compliance.schemas``. This module is re-exported
from ``compliance.api.schemas`` for backwards compatibility.
"""

from datetime import datetime, date
from typing import Optional, List, Any, Dict

from pydantic import BaseModel, ConfigDict, Field

from compliance.schemas.common import (
    PaginationMeta, RegulationType, ControlType, ControlDomain,
    ControlStatus, RiskLevel, EvidenceStatus,
)


# ============================================================================
# Evidence Schemas
# ============================================================================

class EvidenceBase(BaseModel):
    control_id: str
    evidence_type: str
    title: str
    description: Optional[str] = None
    artifact_url: Optional[str] = None
    valid_from: Optional[datetime] = None
    valid_until: Optional[datetime] = None
    source: Optional[str] = None
    ci_job_id: Optional[str] = None


class EvidenceCreate(EvidenceBase):
    pass


class EvidenceResponse(EvidenceBase):
    id: str
    artifact_path: Optional[str] = None
    artifact_hash: Optional[str] = None
    file_size_bytes: Optional[int] = None
    mime_type: Optional[str] = None
    status: str
    uploaded_by: Optional[str] = None
    collected_at: datetime
    created_at: datetime

    model_config = ConfigDict(from_attributes=True)


class EvidenceListResponse(BaseModel):
    evidence: List[EvidenceResponse]
    total: int


class EvidenceCollectRequest(BaseModel):
    """Request to auto-collect evidence from CI."""
    control_id: str
    evidence_type: str
    title: str
    ci_job_id: str
    artifact_url: str

