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

from __future__ import annotations
from gr4vy.errors import Gr4vyError
from gr4vy.models import errordetail as models_errordetail
from gr4vy.types import BaseModel
from gr4vy.utils import validate_const
import httpx
import pydantic
from pydantic.functional_validators import AfterValidator
from typing import List, Literal, Optional
from typing_extensions import Annotated


class Error405Data(BaseModel):
    TYPE: Annotated[
        Annotated[Optional[Literal["error"]], AfterValidator(validate_const("error"))],
        pydantic.Field(alias="type"),
    ] = "error"
    r"""Always `error`."""

    code: Optional[str] = "method_not_allowed"
    r"""Always `method_not_allowed`"""

    status: Optional[int] = 405
    r"""Always `405`."""

    message: Optional[str] = "Method Not Allowed"
    r"""A human readable message that provides more context to the error."""

    details: Optional[List[models_errordetail.ErrorDetail]] = None
    r"""A list of details that further ellaborate on the error."""


class Error405(Gr4vyError):
    data: Error405Data

    def __init__(
        self,
        data: Error405Data,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        fallback = body or raw_response.text
        message = str(data.message) or fallback
        super().__init__(message, raw_response, body)
        self.data = data
