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

from __future__ import annotations
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
from pydantic import model_serializer
from typing import List
from typing_extensions import TypedDict


class WorkspaceTypedDict(TypedDict):
    created_at: str
    r"""ISO 8601 timestamp of when the workspace was created"""
    created_by: Nullable[str]
    r"""User ID of the workspace creator"""
    default_image_model: Nullable[str]
    r"""Default image model for this workspace"""
    default_provider_sort: Nullable[str]
    r"""Default provider sort preference (price, throughput, latency, exacto)"""
    default_text_model: Nullable[str]
    r"""Default text model for this workspace"""
    description: Nullable[str]
    r"""Description of the workspace"""
    id: str
    r"""Unique identifier for the workspace"""
    io_logging_api_key_ids: Nullable[List[int]]
    r"""Optional array of API key IDs to filter I/O logging. Null means all keys are logged."""
    io_logging_sampling_rate: float
    r"""Sampling rate for I/O logging (0.0001-1). 1 means 100% of requests are logged."""
    is_data_discount_logging_enabled: bool
    r"""Whether data discount logging is enabled for this workspace"""
    is_observability_broadcast_enabled: bool
    r"""Whether broadcast is enabled for this workspace"""
    is_observability_io_logging_enabled: bool
    r"""Whether private logging is enabled for this workspace"""
    name: str
    r"""Name of the workspace"""
    slug: str
    r"""URL-friendly slug for the workspace"""
    updated_at: Nullable[str]
    r"""ISO 8601 timestamp of when the workspace was last updated"""


class Workspace(BaseModel):
    created_at: str
    r"""ISO 8601 timestamp of when the workspace was created"""

    created_by: Nullable[str]
    r"""User ID of the workspace creator"""

    default_image_model: Nullable[str]
    r"""Default image model for this workspace"""

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

    default_text_model: Nullable[str]
    r"""Default text model for this workspace"""

    description: Nullable[str]
    r"""Description of the workspace"""

    id: str
    r"""Unique identifier for the workspace"""

    io_logging_api_key_ids: Nullable[List[int]]
    r"""Optional array of API key IDs to filter I/O logging. Null means all keys are logged."""

    io_logging_sampling_rate: float
    r"""Sampling rate for I/O logging (0.0001-1). 1 means 100% of requests are logged."""

    is_data_discount_logging_enabled: bool
    r"""Whether data discount logging is enabled for this workspace"""

    is_observability_broadcast_enabled: bool
    r"""Whether broadcast is enabled for this workspace"""

    is_observability_io_logging_enabled: bool
    r"""Whether private logging is enabled for this workspace"""

    name: str
    r"""Name of the workspace"""

    slug: str
    r"""URL-friendly slug for the workspace"""

    updated_at: Nullable[str]
    r"""ISO 8601 timestamp of when the workspace was last updated"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = [
            "created_by",
            "default_image_model",
            "default_provider_sort",
            "default_text_model",
            "description",
            "io_logging_api_key_ids",
            "updated_at",
        ]
        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
