"""Response types for the ConfigPig API."""

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Generic, TypeVar

T = TypeVar("T")


@dataclass
class APIResponse(Generic[T]):
    """Wrapper for all API responses. Check `ok` before accessing `data`."""

    ok: bool
    status_code: int
    data: T | None = None
    error: str | None = None


# ── Config types ──


@dataclass
class LabelInfo:
    label_name: str
    version_number: int
    is_system: bool
    updated_at: str


@dataclass
class Config:
    id: str
    slug: str
    name: str
    description: str
    format: str
    tags: list[str]
    version_count: int
    labels: list[LabelInfo]
    created_at: str
    updated_at: str


@dataclass
class ConfigSummary:
    id: str
    slug: str
    name: str
    description: str
    format: str
    tags: list[str]
    version_count: int
    updated_at: str


@dataclass
class ConfigVersion:
    id: str
    version_number: int
    content: str
    change_note: str
    created_by: str | None
    created_at: str


@dataclass
class FetchResult:
    content: str
    format: str
    version_number: int
    label: str


# ── Label types ──


@dataclass
class TeamLabel:
    id: str
    name: str
    is_protected: bool
    is_system: bool
    description: str
    created_at: str


@dataclass
class ConfigLabel:
    label_name: str
    version_number: int
    is_system: bool
    updated_at: str


# ── Export types ──


@dataclass
class Export:
    id: str
    name: str
    description: str
    created_by: str | None
    created_at: str


# ── System types ──


@dataclass
class HealthCheck:
    status: str
    version: str
    timestamp: str
