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

from __future__ import annotations
from kombo.types import BaseModel, Nullable, UNSET_SENTINEL
from kombo.utils import validate_const
import pydantic
from pydantic import model_serializer
from pydantic.functional_validators import AfterValidator
from typing import Literal
from typing_extensions import Annotated, TypedDict


PatchIntegrationsIntegrationIDIntegrationFieldsIntegrationFieldIDPositiveResponseType = Literal[
    "DEFAULT",
    "CUSTOM",
]
r"""The type of the integration field. There is a type to avoid collisions between DEFAULT fields and CUSTOM fields with the same key."""


class PatchIntegrationsIntegrationIDIntegrationFieldsIntegrationFieldIDPositiveResponseDataTypedDict(
    TypedDict
):
    id: str
    r"""The unique ID of the field."""
    key: str
    r"""The key of the field in the remote system."""
    model: str
    r"""The model the field is associated with."""
    type: PatchIntegrationsIntegrationIDIntegrationFieldsIntegrationFieldIDPositiveResponseType
    r"""The type of the integration field. There is a type to avoid collisions between DEFAULT fields and CUSTOM fields with the same key."""
    label: Nullable[str]
    r"""The label of the field in the remote system."""
    is_passthrough_enabled: bool
    r"""Whether the field is included in the integrations_fields array of the corresponding model."""
    is_writable: Literal[False]
    r"""This field is related to a deprecated feature and means nothing, but is kept for backwards compatibility."""


class PatchIntegrationsIntegrationIDIntegrationFieldsIntegrationFieldIDPositiveResponseData(
    BaseModel
):
    id: str
    r"""The unique ID of the field."""

    key: str
    r"""The key of the field in the remote system."""

    model: str
    r"""The model the field is associated with."""

    type: PatchIntegrationsIntegrationIDIntegrationFieldsIntegrationFieldIDPositiveResponseType
    r"""The type of the integration field. There is a type to avoid collisions between DEFAULT fields and CUSTOM fields with the same key."""

    label: Nullable[str]
    r"""The label of the field in the remote system."""

    is_passthrough_enabled: bool
    r"""Whether the field is included in the integrations_fields array of the corresponding model."""

    IS_WRITABLE: Annotated[
        Annotated[Literal[False], AfterValidator(validate_const(False))],
        pydantic.Field(alias="is_writable"),
    ] = False
    r"""This field is related to a deprecated feature and means nothing, but is kept for backwards compatibility."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        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:
                m[k] = val

        return m


class PatchIntegrationsIntegrationIDIntegrationFieldsIntegrationFieldIDPositiveResponseTypedDict(
    TypedDict
):
    data: PatchIntegrationsIntegrationIDIntegrationFieldsIntegrationFieldIDPositiveResponseDataTypedDict
    status: Literal["success"]


class PatchIntegrationsIntegrationIDIntegrationFieldsIntegrationFieldIDPositiveResponse(
    BaseModel
):
    data: PatchIntegrationsIntegrationIDIntegrationFieldsIntegrationFieldIDPositiveResponseData

    STATUS: Annotated[
        Annotated[Literal["success"], AfterValidator(validate_const("success"))],
        pydantic.Field(alias="status"),
    ] = "success"


try:
    PatchIntegrationsIntegrationIDIntegrationFieldsIntegrationFieldIDPositiveResponseData.model_rebuild()
except NameError:
    pass
try:
    PatchIntegrationsIntegrationIDIntegrationFieldsIntegrationFieldIDPositiveResponse.model_rebuild()
except NameError:
    pass
