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

from __future__ import annotations
from kombo.types import BaseModel, Nullable, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Literal
from typing_extensions import TypedDict


KomboGeneralErrorStatus = Literal["error",]


KomboGeneralErrorCode = Literal[
    "PLATFORM.RATE_LIMIT_EXCEEDED",
    "PLATFORM.CONCURRENCY_LIMIT_EXCEEDED",
    "PLATFORM.INTEGRATION_NOT_FOUND",
    "PLATFORM.INPUT_INVALID",
    "PLATFORM.UNKNOWN_ERROR",
    "PLATFORM.IP_NOT_WHITELISTED",
    "PLATFORM.AUTHENTICATION_INVALID",
    "PLATFORM.TASK_TIMED_OUT",
]
r"""Some errors include an error code that can be used to identify their cause. See the [Error Handling Docs](https://docs.kombo.dev/guides/errors) for more information. For your error handling logic please use the error `code` instead of other properties (e.g. message, http status code, ...)."""


class KomboGeneralErrorErrorTypedDict(TypedDict):
    r"""Error details with structured code for programmatic handling."""

    code: Nullable[KomboGeneralErrorCode]
    r"""Some errors include an error code that can be used to identify their cause. See the [Error Handling Docs](https://docs.kombo.dev/guides/errors) for more information. For your error handling logic please use the error `code` instead of other properties (e.g. message, http status code, ...)."""
    title: Nullable[str]
    r"""A static, human-readable label."""
    message: str
    r"""A dynamic, detailed description of what went wrong in this specific instance."""
    log_url: Nullable[str]
    r"""The log page in the Kombo UI lists every interaction with full details. If you need assistance, share that link with our support team."""


class KomboGeneralErrorError(BaseModel):
    r"""Error details with structured code for programmatic handling."""

    code: Nullable[KomboGeneralErrorCode]
    r"""Some errors include an error code that can be used to identify their cause. See the [Error Handling Docs](https://docs.kombo.dev/guides/errors) for more information. For your error handling logic please use the error `code` instead of other properties (e.g. message, http status code, ...)."""

    title: Nullable[str]
    r"""A static, human-readable label."""

    message: str
    r"""A dynamic, detailed description of what went wrong in this specific instance."""

    log_url: Nullable[str]
    r"""The log page in the Kombo UI lists every interaction with full details. If you need assistance, share that link with our support team."""

    @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
