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

from __future__ import annotations
from dataclasses import dataclass, field
import httpx
from typing import Optional
from unkey.py.errors import UnkeyError
from unkey.py.models import baseerror as models_baseerror, meta as models_meta
from unkey.py.types import BaseModel


class UnprocessableEntityErrorResponseData(BaseModel):
    meta: models_meta.Meta
    r"""Metadata object included in every API response. This provides context about the request and is essential for debugging, audit trails, and support inquiries. The `requestId` is particularly important when troubleshooting issues with the Unkey support team."""

    error: models_baseerror.BaseError
    r"""Base error structure following Problem Details for HTTP APIs (RFC 7807). This provides a standardized way to carry machine-readable details of errors in HTTP response content."""


@dataclass(unsafe_hash=True)
class UnprocessableEntityErrorResponse(UnkeyError):
    r"""Error response when the request is syntactically valid but cannot be processed due to semantic constraints or resource limitations. This occurs when:
    - A query exceeds execution time limits
    - A query uses more memory than allowed
    - A query scans too many rows
    - A query result exceeds size limits

    The request syntax is correct, but the operation cannot be completed due to business rules or resource constraints. Review the error details for specific limitations and adjust your request accordingly.
    """

    data: UnprocessableEntityErrorResponseData = field(hash=False)

    def __init__(
        self,
        data: UnprocessableEntityErrorResponseData,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        message = body or raw_response.text
        super().__init__(message, raw_response, body)
        object.__setattr__(self, "data", data)
