"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
# @generated-id: ba3265f85453

from __future__ import annotations
from mistralai.client.types import BaseModel, UNSET_SENTINEL
from mistralai.client.utils import validate_const
import pydantic
from pydantic import model_serializer
from pydantic.functional_validators import AfterValidator
from typing import Any, Literal, Optional
from typing_extensions import Annotated, TypedDict


class JSONPayloadResponseTypedDict(TypedDict):
    r"""A payload containing arbitrary JSON data.

    Used for complete state snapshots or final results.
    """

    value: Any
    r"""The JSON-serializable payload value."""
    type: Literal["json"]
    r"""Discriminator indicating this is a raw JSON payload."""


class JSONPayloadResponse(BaseModel):
    r"""A payload containing arbitrary JSON data.

    Used for complete state snapshots or final results.
    """

    value: Any
    r"""The JSON-serializable payload value."""

    type: Annotated[
        Annotated[Optional[Literal["json"]], AfterValidator(validate_const("json"))],
        pydantic.Field(alias="type"),
    ] = "json"
    r"""Discriminator indicating this is a raw JSON payload."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["type"])
        serialized = handler(self)
        m = {}

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

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

        return m


try:
    JSONPayloadResponse.model_rebuild()
except NameError:
    pass
