# Generated by @docstream/fastapi-server-emitter
# Do not edit this file manually — regenerate with: tsp compile .
# This file contains Pydantic v2 models and enums generated from TypeSpec.
from __future__ import annotations

from enum import Enum
from pydantic import BaseModel, Field, ConfigDict

from .common import RendererConfig

class Transport(str, Enum):
    """Transport mechanism for a source."""
    # Local filesystem path.
    local = "local"
    # SSH remote host:path pair.
    ssh = "ssh"
    # SSH over a WireGuard network.
    wireguard = "wireguard"

class Context(BaseModel):
    """A context is a named namespace that groups one or more sources. The context id is a URL-safe slug, supplied by the client on creation, and is immutable. Context-Docs are served under `/<context-id>/`."""
    id: str = Field(..., description="URL-safe slug, immutable after creation.")
    sources: list[Source] = Field(..., description="Sources belonging to this context.")
    renderer: RendererConfig | None = Field(None, description="Renderer default for this context; overridden per-source.")

class Source(BaseModel):
    """A source is an input location for Context-Docs. `slug` is server-derived and read-only: from `alias` if present, else the last path segment of `location`. It must be unique within a context."""
    model_config = ConfigDict(populate_by_name=True)
    transport: Transport = Field(..., description="Transport mechanism.")
    location: str = Field(..., description="Location depends on transport: - `local`: absolute filesystem path (e.g. `/path/to/project-docs`) - `ssh` / `wireguard`: `host:path` pair (e.g. `hostA:/path/to/docs`)")
    source_alias: str | None = Field(None, description="Optional human-friendly name. Used to derive `slug` when present. Serialized as `alias` in JSON; the Python field is `source_alias` because `alias` is a Python reserved word.", alias="alias")
    slug: str = Field(..., description="Server-derived, read-only slug. Unique within a context.")
    renderer: RendererConfig | None = Field(None, description="Per-source renderer override; takes precedence over context-level renderer.")

class ContextCreate(BaseModel):
    """Request body for creating a context."""
    id: str
    sources: list[SourceCreate] | None = Field(None)
    renderer: RendererConfig | None = Field(None)

class SourceCreate(BaseModel):
    """Request body for adding a source to a context."""
    model_config = ConfigDict(populate_by_name=True)
    transport: Transport
    location: str
    source_alias: str | None = Field(None, alias="alias")
    renderer: RendererConfig | None = Field(None)

class ContextUpdate(BaseModel):
    """Request body for updating a context's renderer default."""
    renderer: RendererConfig | None = Field(None)

class ContextList(BaseModel):
    """Response body for listing contexts."""
    contexts: list[Context]

class SourceList(BaseModel):
    """Response body for listing sources in a context."""
    sources: list[Source]
