"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from openrouter.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict


class CreateWorkspaceRequestTypedDict(TypedDict):
    name: str
    r"""Name for the new workspace"""
    slug: str
    r"""URL-friendly slug (lowercase alphanumeric segments separated by single hyphens, no leading/trailing hyphens)"""
    default_image_model: NotRequired[Nullable[str]]
    r"""Default image model for this workspace"""
    default_provider_sort: NotRequired[Nullable[str]]
    r"""Default provider sort preference (price, throughput, latency, exacto)"""
    default_text_model: NotRequired[Nullable[str]]
    r"""Default text model for this workspace"""
    description: NotRequired[Nullable[str]]
    r"""Description of the workspace"""
    io_logging_api_key_ids: NotRequired[Nullable[List[int]]]
    r"""Optional array of API key IDs to filter I/O logging"""
    io_logging_sampling_rate: NotRequired[float]
    r"""Sampling rate for I/O logging (0.0001-1)"""
    is_data_discount_logging_enabled: NotRequired[bool]
    r"""Whether data discount logging is enabled"""
    is_observability_broadcast_enabled: NotRequired[bool]
    r"""Whether broadcast is enabled"""
    is_observability_io_logging_enabled: NotRequired[bool]
    r"""Whether private logging is enabled"""


class CreateWorkspaceRequest(BaseModel):
    name: str
    r"""Name for the new workspace"""

    slug: str
    r"""URL-friendly slug (lowercase alphanumeric segments separated by single hyphens, no leading/trailing hyphens)"""

    default_image_model: OptionalNullable[str] = UNSET
    r"""Default image model for this workspace"""

    default_provider_sort: OptionalNullable[str] = UNSET
    r"""Default provider sort preference (price, throughput, latency, exacto)"""

    default_text_model: OptionalNullable[str] = UNSET
    r"""Default text model for this workspace"""

    description: OptionalNullable[str] = UNSET
    r"""Description of the workspace"""

    io_logging_api_key_ids: OptionalNullable[List[int]] = UNSET
    r"""Optional array of API key IDs to filter I/O logging"""

    io_logging_sampling_rate: Optional[float] = None
    r"""Sampling rate for I/O logging (0.0001-1)"""

    is_data_discount_logging_enabled: Optional[bool] = None
    r"""Whether data discount logging is enabled"""

    is_observability_broadcast_enabled: Optional[bool] = None
    r"""Whether broadcast is enabled"""

    is_observability_io_logging_enabled: Optional[bool] = None
    r"""Whether private logging is enabled"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "default_image_model",
            "default_provider_sort",
            "default_text_model",
            "description",
            "io_logging_api_key_ids",
            "io_logging_sampling_rate",
            "is_data_discount_logging_enabled",
            "is_observability_broadcast_enabled",
            "is_observability_io_logging_enabled",
        ]
        nullable_fields = [
            "default_image_model",
            "default_provider_sort",
            "default_text_model",
            "description",
            "io_logging_api_key_ids",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m
