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

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


class DataSourceDetailResponseTypedDict(TypedDict):
    r"""Metadata about a data source, along with the text. A data source is a blob of text that
    can be made available to an agent's general info tools to provide more context to the agent when
    generating its responses. For more information, see
    [Console docs](https://docs.syllable.ai/Resources/DataSources).
    """

    name: str
    r"""The data source name. Must be unique within suborg. Cannot contain whitespace."""
    chunk: bool
    r"""Whether the content should be split into smaller chunks. (This feature is coming in the future - currently this value will always be treated as False.)"""
    id: int
    r"""The data source ID."""
    updated_at: datetime
    r"""Timestamp of most recent update"""
    last_updated_by: Nullable[str]
    r"""Email of the user who last updated the data source"""
    text: str
    r"""Information that the data source will provide to the agent accessing it."""
    description: NotRequired[Nullable[str]]
    r"""The description of the data source."""
    labels: NotRequired[List[str]]
    r"""Searchable labels for the data source. Can be included in agent.prompt_tool_defaults for a given tool to give the agent access to data sources with those labels when calling that tool."""
    chunk_delimiter: NotRequired[Nullable[str]]
    r"""String that should be treated as delimiter between intended chunks. (This feature is coming in the future - currently this value will always be treated as None.)"""
    edit_comments: NotRequired[Nullable[str]]
    r"""The comments for the most recent edit to the data source"""


class DataSourceDetailResponse(BaseModel):
    r"""Metadata about a data source, along with the text. A data source is a blob of text that
    can be made available to an agent's general info tools to provide more context to the agent when
    generating its responses. For more information, see
    [Console docs](https://docs.syllable.ai/Resources/DataSources).
    """

    name: str
    r"""The data source name. Must be unique within suborg. Cannot contain whitespace."""

    chunk: bool
    r"""Whether the content should be split into smaller chunks. (This feature is coming in the future - currently this value will always be treated as False.)"""

    id: int
    r"""The data source ID."""

    updated_at: datetime
    r"""Timestamp of most recent update"""

    last_updated_by: Nullable[str]
    r"""Email of the user who last updated the data source"""

    text: str
    r"""Information that the data source will provide to the agent accessing it."""

    description: OptionalNullable[str] = UNSET
    r"""The description of the data source."""

    labels: Optional[List[str]] = None
    r"""Searchable labels for the data source. Can be included in agent.prompt_tool_defaults for a given tool to give the agent access to data sources with those labels when calling that tool."""

    chunk_delimiter: OptionalNullable[str] = UNSET
    r"""String that should be treated as delimiter between intended chunks. (This feature is coming in the future - currently this value will always be treated as None.)"""

    edit_comments: OptionalNullable[str] = UNSET
    r"""The comments for the most recent edit to the data source"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["description", "labels", "chunk_delimiter", "edit_comments"]
        )
        nullable_fields = set(
            ["description", "chunk_delimiter", "edit_comments", "last_updated_by"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m
