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

from __future__ import annotations
from .constraintvalidation import ConstraintValidation
from novu_py import utils
from novu_py.types import BaseModel, Nullable, OptionalNullable, UNSET
import pydantic
from typing import Any, Dict, List, Optional, Union
from typing_extensions import Annotated, TypeAliasType, TypedDict


MessageValidationErrorDto5TypedDict = TypeAliasType(
    "MessageValidationErrorDto5TypedDict", Union[str, float, bool, Dict[str, Any]]
)


MessageValidationErrorDto5 = TypeAliasType(
    "MessageValidationErrorDto5", Union[str, float, bool, Dict[str, Any]]
)


class MessageValidationErrorDto4TypedDict(TypedDict):
    pass


class MessageValidationErrorDto4(BaseModel):
    pass


ValidationErrorDtoMessageTypedDict = TypeAliasType(
    "ValidationErrorDtoMessageTypedDict",
    Union[
        MessageValidationErrorDto4TypedDict,
        str,
        float,
        bool,
        List[Nullable[MessageValidationErrorDto5TypedDict]],
    ],
)
r"""Value that failed validation"""


ValidationErrorDtoMessage = TypeAliasType(
    "ValidationErrorDtoMessage",
    Union[
        MessageValidationErrorDto4,
        str,
        float,
        bool,
        List[Nullable[MessageValidationErrorDto5]],
    ],
)
r"""Value that failed validation"""


class ValidationErrorDtoData(BaseModel):
    status_code: Annotated[float, pydantic.Field(alias="statusCode")]
    r"""HTTP status code of the error response."""

    timestamp: str
    r"""Timestamp of when the error occurred."""

    path: str
    r"""The path where the error occurred."""

    errors: Dict[str, ConstraintValidation]
    r"""A record of validation errors keyed by field name"""

    message: OptionalNullable[ValidationErrorDtoMessage] = UNSET
    r"""Value that failed validation"""

    ctx: Optional[Dict[str, Any]] = None
    r"""Optional context object for additional error details."""

    error_id: Annotated[Optional[str], pydantic.Field(alias="errorId")] = None
    r"""Optional unique identifier for the error, useful for tracking using Sentry and
    New Relic, only available for 500.
    """


class ValidationErrorDto(Exception):
    data: ValidationErrorDtoData

    def __init__(self, data: ValidationErrorDtoData):
        self.data = data

    def __str__(self) -> str:
        return utils.marshal_json(self.data, ValidationErrorDtoData)
