# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List, Optional
from datetime import datetime

from ..._models import BaseModel

__all__ = ["RelayCreateResponse", "Config", "ConfigLingeringSubscribe", "ConfigUpstreams", "ConfigUpstreamsUpstream"]


class ConfigLingeringSubscribe(BaseModel):
    enabled: Optional[bool] = None

    max_timeout_ms: Optional[int] = None
    """Relay-level ceiling on lingering subscribe timeout (ms). Default 30000."""


class ConfigUpstreamsUpstream(BaseModel):
    """A single upstream MOQT server publisher."""

    url: Optional[str] = None
    """Upstream MOQT server publisher URL."""


class ConfigUpstreams(BaseModel):
    """
    Upstreams are external MOQT server publishers that a relay falls back
    to when it has no local publisher for a requested namespace/track.
    """

    enabled: Optional[bool] = None

    upstreams: Optional[List[ConfigUpstreamsUpstream]] = None
    """Ordered list of upstream MOQT server publishers.

    Each entry is an object (not a bare string) so per-upstream configuration can be
    added in the future without another breaking change.
    """


class Config(BaseModel):
    """upstreams and lingering_subscribe are mutually exclusive."""

    lingering_subscribe: Optional[ConfigLingeringSubscribe] = None

    upstreams: Optional[ConfigUpstreams] = None
    """
    Upstreams are external MOQT server publishers that a relay falls back to when it
    has no local publisher for a requested namespace/track.
    """


class RelayCreateResponse(BaseModel):
    """Relay with auto-generated tokens (shown once)."""

    config: Config
    """upstreams and lingering_subscribe are mutually exclusive."""

    created: datetime

    modified: datetime

    name: str

    token_publish_subscribe: str
    """Full access token (publish + subscribe). Treat as sensitive."""

    token_subscribe: str
    """Subscribe-only token. Treat as sensitive."""

    uid: str
    """Server-generated unique identifier (32 hex chars)."""
