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

from __future__ import annotations
import httpx
from tofupilot.v2.errors import TofuPilotError
from tofupilot.v2.models import errorbadgateway as models_errorbadgateway
from tofupilot.v2.types import BaseModel
from typing import List, Optional


class ErrorBADGATEWAYData(BaseModel):
    message: str
    r"""The error message"""

    code: str
    r"""The error code"""

    issues: Optional[List[models_errorbadgateway.ErrorBADGATEWAYIssue]] = None
    r"""An array of issues that were responsible for the error"""


class ErrorBADGATEWAY(TofuPilotError):
    r"""Bad gateway error"""

    data: ErrorBADGATEWAYData

    def __init__(
        self,
        data: ErrorBADGATEWAYData,
        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
