"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""

from __future__ import annotations
from dub.types import BaseModel
import dub.utils as utils
from enum import Enum
from typing import Optional, TypedDict
from typing_extensions import NotRequired


class RateLimitExceededCode(str, Enum):
    r"""A short code indicating the error code returned."""
    RATE_LIMIT_EXCEEDED = "rate_limit_exceeded"


class RateLimitExceededErrorTypedDict(TypedDict):
    code: RateLimitExceededCode
    r"""A short code indicating the error code returned."""
    message: str
    r"""A human readable explanation of what went wrong."""
    doc_url: NotRequired[str]
    r"""A link to our documentation with more details about this error code"""
    

class RateLimitExceededError(BaseModel):
    code: RateLimitExceededCode
    r"""A short code indicating the error code returned."""
    message: str
    r"""A human readable explanation of what went wrong."""
    doc_url: Optional[str] = None
    r"""A link to our documentation with more details about this error code"""
    
class RateLimitExceededData(BaseModel):
    error: RateLimitExceededError
    


class RateLimitExceeded(Exception):
    r"""The user has sent too many requests in a given amount of time (\"rate limiting\")"""
    data: RateLimitExceededData

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

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

