"""
This type stub file was generated by pyright.
"""

import nats.errors
from dataclasses import dataclass
from typing import Any, Dict, NoReturn, Optional, TYPE_CHECKING
from nats.aio.msg import Msg

if TYPE_CHECKING:
    ...
class Error(nats.errors.Error):
    """
    An Error raised by the NATS client when using JetStream.
    """
    def __init__(self, description: Optional[str] = ...) -> None:
        ...
    
    def __str__(self) -> str:
        ...
    


@dataclass(repr=False, init=False)
class APIError(Error):
    """
    An Error that is the result of interacting with NATS JetStream.
    """
    code: Optional[int]
    err_code: Optional[int]
    description: Optional[str]
    stream: Optional[str]
    seq: Optional[int]
    def __init__(self, code: Optional[int] = ..., description: Optional[str] = ..., err_code: Optional[int] = ..., stream: Optional[str] = ..., seq: Optional[int] = ...) -> None:
        ...
    
    @classmethod
    def from_msg(cls, msg: Msg) -> NoReturn:
        ...
    
    @classmethod
    def from_error(cls, err: Dict[str, Any]):
        ...
    
    def __str__(self) -> str:
        ...
    


class ServiceUnavailableError(APIError):
    """
    A 503 error
    """
    ...


class ServerError(APIError):
    """
    A 500 error
    """
    ...


class NotFoundError(APIError):
    """
    A 404 error
    """
    ...


class BadRequestError(APIError):
    """
    A 400 error.
    """
    ...


class NoStreamResponseError(Error):
    """
    Raised if the client gets a 503 when publishing a message.
    """
    def __str__(self) -> str:
        ...
    


class FetchTimeoutError(nats.errors.TimeoutError):
    """
    Raised if the consumer timed out waiting for messages.
    """
    def __str__(self) -> str:
        ...
    


class ConsumerSequenceMismatchError(Error):
    """
    Async error raised by the client with idle_heartbeat mode enabled
    when one of the message sequences is not the expected one.
    """
    def __init__(self, stream_resume_sequence=..., consumer_sequence=..., last_consumer_sequence=...) -> None:
        ...
    
    def __str__(self) -> str:
        ...
    


class BucketNotFoundError(NotFoundError):
    """
    When attempted to bind to a JetStream KeyValue that does not exist.
    """
    ...


class BadBucketError(APIError):
    ...


class KeyValueError(APIError):
    """
    Raised when there is an issue interacting with the KeyValue store.
    """
    ...


class KeyDeletedError(KeyValueError, NotFoundError):
    """
    Raised when trying to get a key that was deleted from a JetStream KeyValue store.
    """
    def __init__(self, entry=..., op=...) -> None:
        ...
    
    def __str__(self) -> str:
        ...
    


class KeyNotFoundError(KeyValueError, NotFoundError):
    """
    Raised when trying to get a key that does not exists from a JetStream KeyValue store.
    """
    def __init__(self, entry=..., op=..., message=...) -> None:
        ...
    
    def __str__(self) -> str:
        ...
    


class KeyWrongLastSequenceError(KeyValueError, BadRequestError):
    """
    Raised when trying to update a key with the wrong last sequence.
    """
    def __init__(self, description=...) -> None:
        ...
    
    def __str__(self) -> str:
        ...
    


class NoKeysError(KeyValueError):
    def __str__(self) -> str:
        ...
    


class KeyHistoryTooLargeError(KeyValueError):
    def __str__(self) -> str:
        ...
    


class InvalidBucketNameError(Error):
    """
    Raised when trying to create a KV or OBJ bucket with invalid name.
    """
    ...


class InvalidObjectNameError(Error):
    """
    Raised when trying to put an object in Object Store with invalid key.
    """
    ...


class BadObjectMetaError(Error):
    """
    Raised when trying to read corrupted metadata from Object Store.
    """
    ...


class LinkIsABucketError(Error):
    """
    Raised when trying to get object from Object Store that is a bucket.
    """
    ...


class DigestMismatchError(Error):
    """
    Raised when getting an object from Object Store that has a different digest than expected.
    """
    ...


class ObjectNotFoundError(NotFoundError):
    """
    When attempted to lookup an Object that does not exist.
    """
    ...


class ObjectDeletedError(NotFoundError):
    """
    When attempted to do an operation to an Object that does not exist.
    """
    ...


class ObjectAlreadyExists(Error):
    """
    When attempted to do an operation to an Object that already exist.
    """
    ...


