"""
Incident / Datenpannen schemas (DSGVO Art. 33/34).

Phase 1 Step 4: extracted from ``compliance.api.incident_routes``.
"""

from typing import List, Optional

from pydantic import BaseModel


class IncidentCreate(BaseModel):
    title: str
    description: Optional[str] = None
    category: Optional[str] = "data_breach"
    severity: Optional[str] = "medium"
    detected_at: Optional[str] = None
    affected_data_categories: Optional[List[str]] = None
    affected_data_subject_count: Optional[int] = 0
    affected_systems: Optional[List[str]] = None


class IncidentUpdate(BaseModel):
    title: Optional[str] = None
    description: Optional[str] = None
    category: Optional[str] = None
    status: Optional[str] = None
    severity: Optional[str] = None
    affected_data_categories: Optional[List[str]] = None
    affected_data_subject_count: Optional[int] = None
    affected_systems: Optional[List[str]] = None


class StatusUpdate(BaseModel):
    status: str


class RiskAssessmentRequest(BaseModel):
    likelihood: int
    impact: int
    notes: Optional[str] = None


class AuthorityNotificationRequest(BaseModel):
    authority_name: str
    reference_number: Optional[str] = None
    contact_person: Optional[str] = None
    notes: Optional[str] = None


class DataSubjectNotificationRequest(BaseModel):
    notification_text: str
    channel: str = "email"
    affected_count: Optional[int] = 0


class MeasureCreate(BaseModel):
    title: str
    description: Optional[str] = None
    measure_type: str = "corrective"
    responsible: Optional[str] = None
    due_date: Optional[str] = None


class MeasureUpdate(BaseModel):
    title: Optional[str] = None
    description: Optional[str] = None
    measure_type: Optional[str] = None
    status: Optional[str] = None
    responsible: Optional[str] = None
    due_date: Optional[str] = None


class TimelineEntryRequest(BaseModel):
    action: str
    details: Optional[str] = None


class CloseIncidentRequest(BaseModel):
    root_cause: str
    lessons_learned: Optional[str] = None


__all__ = [
    "IncidentCreate",
    "IncidentUpdate",
    "StatusUpdate",
    "RiskAssessmentRequest",
    "AuthorityNotificationRequest",
    "DataSubjectNotificationRequest",
    "MeasureCreate",
    "MeasureUpdate",
    "TimelineEntryRequest",
    "CloseIncidentRequest",
]
