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

from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, List, Optional, TypeVar

_NANOSECOND = ...
class Header(str, Enum):
    CONSUMER_STALLED = ...
    DESCRIPTION = ...
    EXPECTED_LAST_MSG_ID = ...
    EXPECTED_LAST_SEQUENCE = ...
    EXPECTED_LAST_SUBJECT_SEQUENCE = ...
    EXPECTED_STREAM = ...
    LAST_CONSUMER = ...
    LAST_STREAM = ...
    MSG_ID = ...
    ROLLUP = ...
    STATUS = ...


DEFAULT_PREFIX = ...
INBOX_PREFIX = ...
class StatusCode(str, Enum):
    SERVICE_UNAVAILABLE = ...
    NO_MESSAGES = ...
    REQUEST_TIMEOUT = ...
    CONFLICT = ...
    CONTROL_MESSAGE = ...


_B = TypeVar("_B", bound="Base")
@dataclass
class Base:
    """
    Helper dataclass to filter unknown fields from the API.
    """
    @classmethod
    def from_response(cls: type[_B], resp: Dict[str, Any]) -> _B:
        """Read the class instance from a server response.

        Unknown fields are ignored ("open-world assumption").
        """
        ...
    
    def evolve(self: _B, **params) -> _B:
        """Return a copy of the instance with the passed values replaced.
        """
        ...
    
    def as_dict(self) -> Dict[str, object]:
        """Return the object converted into an API-friendly dict.
        """
        ...
    


@dataclass
class PubAck(Base):
    """
    PubAck is the response of publishing a message to JetStream.
    """
    stream: str
    seq: int
    domain: Optional[str] = ...
    duplicate: Optional[bool] = ...


@dataclass
class Placement(Base):
    """Placement directives to consider when placing replicas of this stream"""
    cluster: Optional[str] = ...
    tags: Optional[List[str]] = ...


@dataclass
class ExternalStream(Base):
    api: str
    deliver: Optional[str] = ...
    def as_dict(self) -> Dict[str, object]:
        ...
    


@dataclass
class StreamSource(Base):
    name: str
    opt_start_seq: Optional[int] = ...
    filter_subject: Optional[str] = ...
    external: Optional[ExternalStream] = ...
    subject_transforms: Optional[List[SubjectTransform]] = ...
    @classmethod
    def from_response(cls, resp: Dict[str, Any]): # -> Self:
        ...
    
    def as_dict(self) -> Dict[str, object]:
        ...
    


@dataclass
class StreamSourceInfo(Base):
    name: str
    lag: Optional[int] = ...
    active: Optional[int] = ...
    error: Optional[Dict[str, Any]] = ...


@dataclass
class LostStreamData(Base):
    msgs: Optional[List[int]] = ...
    bytes: Optional[int] = ...


@dataclass
class StreamState(Base):
    messages: int
    bytes: int
    first_seq: int
    last_seq: int
    consumer_count: int
    deleted: Optional[List[int]] = ...
    num_deleted: Optional[int] = ...
    lost: Optional[LostStreamData] = ...
    subjects: Optional[Dict[str, int]] = ...
    @classmethod
    def from_response(cls, resp: Dict[str, Any]): # -> Self:
        ...
    


class RetentionPolicy(str, Enum):
    """How message retention is considered"""
    LIMITS = ...
    INTEREST = ...
    WORK_QUEUE = ...


class StorageType(str, Enum):
    """The type of storage backend"""
    FILE = ...
    MEMORY = ...


class DiscardPolicy(str, Enum):
    """Discard policy when a stream reaches its limits"""
    OLD = ...
    NEW = ...


class StoreCompression(str, Enum):
    """
    If stream is file-based and a compression algorithm is specified,
    the stream data will be compressed on disk.

    Valid options are none or s2 for Snappy compression.
    Introduced in nats-server 2.10.0.
    """
    NONE = ...
    S2 = ...


@dataclass
class RePublish(Base):
    """
    RePublish is for republishing messages once committed to a stream. The original
    subject cis remapped from the subject pattern to the destination pattern.
    """
    src: Optional[str] = ...
    dest: Optional[str] = ...
    headers_only: Optional[bool] = ...


@dataclass
class SubjectTransform(Base):
    """Subject transform to apply to matching messages."""
    src: str
    dest: str
    def as_dict(self) -> Dict[str, object]:
        ...
    


@dataclass
class StreamConfig(Base):
    """
    StreamConfig represents the configuration of a stream.
    """
    name: Optional[str] = ...
    description: Optional[str] = ...
    subjects: Optional[List[str]] = ...
    retention: Optional[RetentionPolicy] = ...
    max_consumers: Optional[int] = ...
    max_msgs: Optional[int] = ...
    max_bytes: Optional[int] = ...
    discard: Optional[DiscardPolicy] = ...
    max_age: Optional[float] = ...
    max_msgs_per_subject: int = ...
    max_msg_size: Optional[int] = ...
    storage: Optional[StorageType] = ...
    num_replicas: Optional[int] = ...
    no_ack: bool = ...
    template_owner: Optional[str] = ...
    duplicate_window: float = ...
    placement: Optional[Placement] = ...
    mirror: Optional[StreamSource] = ...
    sources: Optional[List[StreamSource]] = ...
    sealed: bool = ...
    deny_delete: bool = ...
    deny_purge: bool = ...
    allow_rollup_hdrs: bool = ...
    republish: Optional[RePublish] = ...
    subject_transform: Optional[SubjectTransform] = ...
    allow_direct: Optional[bool] = ...
    mirror_direct: Optional[bool] = ...
    compression: Optional[StoreCompression] = ...
    metadata: Optional[Dict[str, str]] = ...
    @classmethod
    def from_response(cls, resp: Dict[str, Any]): # -> Self:
        ...
    
    def as_dict(self) -> Dict[str, object]:
        ...
    


@dataclass
class PeerInfo(Base):
    name: Optional[str] = ...
    current: Optional[bool] = ...
    offline: Optional[bool] = ...
    active: Optional[int] = ...
    lag: Optional[int] = ...


@dataclass
class ClusterInfo(Base):
    leader: Optional[str] = ...
    name: Optional[str] = ...
    replicas: Optional[List[PeerInfo]] = ...
    @classmethod
    def from_response(cls, resp: Dict[str, Any]): # -> Self:
        ...
    


@dataclass
class StreamInfo(Base):
    """
    StreamInfo is the latest information about a stream from JetStream.
    """
    config: StreamConfig
    state: StreamState
    mirror: Optional[StreamSourceInfo] = ...
    sources: Optional[List[StreamSourceInfo]] = ...
    cluster: Optional[ClusterInfo] = ...
    did_create: Optional[bool] = ...
    @classmethod
    def from_response(cls, resp: Dict[str, Any]): # -> Self:
        ...
    


class AckPolicy(str, Enum):
    """Policies defining how messages should be acknowledged.

    If an ack is required but is not received within the AckWait window, the message will be redelivered.

    References:
        * `Consumers, AckPolicy <https://docs.nats.io/jetstream/concepts/consumers#ackpolicy>`_
    """
    NONE = ...
    ALL = ...
    EXPLICIT = ...


class DeliverPolicy(str, Enum):
    """When a consumer is first created, it can specify where in the stream it wants to start receiving messages.

    This is the DeliverPolicy, and this enumeration defines allowed values.

    References:
        * `Consumers, DeliverPolicy/OptStartSeq/OptStartTime <https://docs.nats.io/jetstream/concepts/consumers#deliverpolicy-optstartseq-optstarttime>`_
    """
    ALL = ...
    LAST = ...
    NEW = ...
    BY_START_SEQUENCE = ...
    BY_START_TIME = ...
    LAST_PER_SUBJECT = ...


class ReplayPolicy(str, Enum):
    """The replay policy applies when the DeliverPolicy is one of:
        * all
        * by_start_sequence
        * by_start_time
    since those deliver policies begin reading the stream at a position other than the end.

    References:
        * `Consumers, ReplayPolicy <https://docs.nats.io/jetstream/concepts/consumers#replaypolicy>`_
    """
    INSTANT = ...
    ORIGINAL = ...


@dataclass
class ConsumerConfig(Base):
    """Consumer configuration.

    References:
        * `Consumers <https://docs.nats.io/jetstream/concepts/consumers>`_
    """
    name: Optional[str] = ...
    durable_name: Optional[str] = ...
    description: Optional[str] = ...
    deliver_policy: Optional[DeliverPolicy] = ...
    opt_start_seq: Optional[int] = ...
    opt_start_time: Optional[int] = ...
    ack_policy: Optional[AckPolicy] = ...
    ack_wait: Optional[float] = ...
    max_deliver: Optional[int] = ...
    backoff: Optional[List[float]] = ...
    filter_subject: Optional[str] = ...
    filter_subjects: Optional[List[str]] = ...
    replay_policy: Optional[ReplayPolicy] = ...
    rate_limit_bps: Optional[int] = ...
    sample_freq: Optional[str] = ...
    max_waiting: Optional[int] = ...
    max_ack_pending: Optional[int] = ...
    flow_control: Optional[bool] = ...
    idle_heartbeat: Optional[float] = ...
    headers_only: Optional[bool] = ...
    deliver_subject: Optional[str] = ...
    deliver_group: Optional[str] = ...
    inactive_threshold: Optional[float] = ...
    num_replicas: Optional[int] = ...
    mem_storage: Optional[bool] = ...
    metadata: Optional[Dict[str, str]] = ...
    @classmethod
    def from_response(cls, resp: Dict[str, Any]): # -> Self:
        ...
    
    def as_dict(self) -> Dict[str, object]:
        ...
    


@dataclass
class SequenceInfo(Base):
    consumer_seq: int
    stream_seq: int
    ...


@dataclass
class ConsumerInfo(Base):
    """
    ConsumerInfo represents the info about the consumer.
    """
    name: str
    stream_name: str
    config: ConsumerConfig
    delivered: Optional[SequenceInfo] = ...
    ack_floor: Optional[SequenceInfo] = ...
    num_ack_pending: Optional[int] = ...
    num_redelivered: Optional[int] = ...
    num_waiting: Optional[int] = ...
    num_pending: Optional[int] = ...
    cluster: Optional[ClusterInfo] = ...
    push_bound: Optional[bool] = ...
    @classmethod
    def from_response(cls, resp: Dict[str, Any]): # -> Self:
        ...
    


@dataclass
class AccountLimits(Base):
    """Account limits

    References:
        * `Multi-tenancy & Resource Mgmt <https://docs.nats.io/jetstream/resource_management>`_
    """
    max_memory: int
    max_storage: int
    max_streams: int
    max_consumers: int
    max_ack_pending: int
    memory_max_stream_bytes: int
    storage_max_stream_bytes: int
    max_bytes_required: bool
    ...


@dataclass
class Tier(Base):
    memory: int
    storage: int
    streams: int
    consumers: int
    limits: AccountLimits
    @classmethod
    def from_response(cls, resp: Dict[str, Any]): # -> Self:
        ...
    


@dataclass
class APIStats(Base):
    """API stats"""
    total: int
    errors: int
    ...


@dataclass
class AccountInfo(Base):
    """Account information

    References:
        * `Account Information <https://docs.nats.io/jetstream/administration/account#account-information>`_
    """
    memory: int
    storage: int
    streams: int
    consumers: int
    limits: AccountLimits
    api: APIStats
    domain: Optional[str] = ...
    tiers: Optional[Dict[str, Tier]] = ...
    @classmethod
    def from_response(cls, resp: Dict[str, Any]): # -> Self:
        ...
    


@dataclass
class RawStreamMsg(Base):
    subject: Optional[str] = ...
    seq: Optional[int] = ...
    data: Optional[bytes] = ...
    hdrs: Optional[bytes] = ...
    headers: Optional[Dict] = ...
    stream: Optional[str] = ...
    @property
    def sequence(self) -> Optional[int]:
        ...
    
    @property
    def header(self) -> Optional[Dict]:
        """
        header returns the headers from a message.
        """
        ...
    


@dataclass
class KeyValueConfig(Base):
    """
    KeyValueConfig is the configuration of a KeyValue store.
    """
    bucket: str
    description: Optional[str] = ...
    max_value_size: Optional[int] = ...
    history: int = ...
    ttl: Optional[float] = ...
    max_bytes: Optional[int] = ...
    storage: Optional[StorageType] = ...
    replicas: int = ...
    placement: Optional[Placement] = ...
    republish: Optional[RePublish] = ...
    direct: Optional[bool] = ...
    def as_dict(self) -> Dict[str, object]:
        ...
    


@dataclass
class StreamPurgeRequest(Base):
    """
    StreamPurgeRequest is optional request information to the purge API.
    """
    seq: Optional[int] = ...
    filter: Optional[str] = ...
    keep: Optional[int] = ...


@dataclass
class ObjectStoreConfig(Base):
    """
    ObjectStoreConfig is the configurigation of an ObjectStore.
    """
    bucket: Optional[str] = ...
    description: Optional[str] = ...
    ttl: Optional[float] = ...
    max_bytes: Optional[int] = ...
    storage: Optional[StorageType] = ...
    replicas: int = ...
    placement: Optional[Placement] = ...
    def as_dict(self) -> Dict[str, object]:
        ...
    


@dataclass
class ObjectLink(Base):
    """
    ObjectLink is used to embed links to other buckets and objects.
    """
    bucket: str
    name: Optional[str] = ...
    @classmethod
    def from_response(cls, resp: Dict[str, Any]): # -> Self:
        ...
    


@dataclass
class ObjectMetaOptions(Base):
    link: Optional[ObjectLink] = ...
    max_chunk_size: Optional[int] = ...
    @classmethod
    def from_response(cls, resp: Dict[str, Any]): # -> Self:
        ...
    


@dataclass
class ObjectMeta(Base):
    """
    ObjectMeta is high level information about an object.
    """
    name: Optional[str] = ...
    description: Optional[str] = ...
    headers: Optional[dict] = ...
    options: Optional[ObjectMetaOptions] = ...
    @classmethod
    def from_response(cls, resp: Dict[str, Any]): # -> Self:
        ...
    


@dataclass
class ObjectInfo(Base):
    """
    ObjectInfo is meta plus instance information.
    """
    name: str
    bucket: str
    nuid: str
    size: Optional[int] = ...
    mtime: Optional[str] = ...
    chunks: Optional[int] = ...
    digest: Optional[str] = ...
    deleted: Optional[bool] = ...
    description: Optional[str] = ...
    headers: Optional[dict] = ...
    options: Optional[ObjectMetaOptions] = ...
    @property
    def meta(self) -> ObjectMeta:
        ...
    
    def is_link(self) -> bool:
        ...
    
    @classmethod
    def from_response(cls, resp: Dict[str, Any]): # -> Self:
        ...
    


