# Auto-generated from OpenAPI - DO NOT EDIT MANUALLY
# Generated: 2025-12-26T18:08:27.342921
# Source: docs-bmad/rabbitmq-http-api-openapi.yaml

# generated by datamodel-codegen:
#   filename:  rabbitmq-http-api-openapi.yaml
#   timestamp: 2025-12-26T21:08:27+00:00

from __future__ import annotations

import re
from typing import Annotated, Any

from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator


class Error(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    error: str | None = None
    reason: str | None = None


class ChannelClosedDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class ChannelCreatedDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class ConnectionClosedDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class ConnectionCreatedDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class QueueCreatedDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class QueueDeclaredDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class QueueDeletedDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class ChurnRates(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    channel_closed: int | None = None
    channel_closed_details: ChannelClosedDetails | None = None
    channel_created: int | None = None
    channel_created_details: ChannelCreatedDetails | None = None
    connection_closed: int | None = None
    connection_closed_details: ConnectionClosedDetails | None = None
    connection_created: int | None = None
    connection_created_details: ConnectionCreatedDetails | None = None
    queue_created: int | None = None
    queue_created_details: QueueCreatedDetails | None = None
    queue_declared: int | None = None
    queue_declared_details: QueueDeclaredDetails | None = None
    queue_deleted: int | None = None
    queue_deleted_details: QueueDeletedDetails | None = None


class Context(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    description: str | None = None
    node: str | None = None
    path: str | None = None
    port: str | None = None
    ssl_opts: list[dict[str, Any]] | None = None


class ExchangeType(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    description: str | None = None
    enabled: bool | None = None
    name: str | None = None
    internal_purpose: str | None = None

    @field_validator("name", mode="after")
    @classmethod
    def validate_exchange_name(cls, v: str) -> str:
        if not v or len(v) > 255:
            raise ValueError("Exchange name must be 1-255 characters")
        if not re.match(r"^[a-zA-Z0-9._-]+$", v):
            raise ValueError(
                "Exchange name must contain only alphanumeric, underscore, dash, dot"
            )
        return v


class SocketOpts(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    backlog: int | None = None
    exit_on_close: bool | None = None
    linger: list[int] | None = None
    nodelay: bool | None = None
    connection_type: str | None = None
    port: int | None = None


class Listener(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    ip_address: str | None = None
    node: str | None = None
    port: int | None = None
    protocol: str | None = None
    socket_opts: SocketOpts | None = None


class AckDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class ConfirmDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class DeliverDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class DeliverGetDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class DeliverNoAckDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class DiskReadsDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class DiskWritesDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class GetDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class GetNoAckDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class PublishDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class RedeliverDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class ReturnUnroutableDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class MessageStats(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    ack: int | None = None
    ack_details: AckDetails | None = None
    confirm: int | None = None
    confirm_details: ConfirmDetails | None = None
    deliver: int | None = None
    deliver_details: DeliverDetails | None = None
    deliver_get: int | None = None
    deliver_get_details: DeliverGetDetails | None = None
    deliver_no_ack: int | None = None
    deliver_no_ack_details: DeliverNoAckDetails | None = None
    disk_reads: int | None = None
    disk_reads_details: DiskReadsDetails | None = None
    disk_writes: int | None = None
    disk_writes_details: DiskWritesDetails | None = None
    get: int | None = None
    get_details: GetDetails | None = None
    get_no_ack: int | None = None
    get_no_ack_details: GetNoAckDetails | None = None
    publish: int | None = None
    publish_details: PublishDetails | None = None
    redeliver: int | None = None
    redeliver_details: RedeliverDetails | None = None
    return_unroutable: int | None = None
    return_unroutable_details: ReturnUnroutableDetails | None = None


class ObjectTotals(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    channels: int | None = None
    connections: int | None = None
    consumers: int | None = None
    exchanges: int | None = None
    queues: int | None = None


class MessagesDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class MessagesReadyDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class MessagesUnacknowledgedDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class QueueTotals(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    messages: int | None = None
    messages_details: MessagesDetails | None = None
    messages_ready: int | None = None
    messages_ready_details: MessagesReadyDetails | None = None
    messages_unacknowledged: int | None = None
    messages_unacknowledged_details: MessagesUnacknowledgedDetails | None = None


class SampleRetentionPolicies(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    basic: list[int] | None = None
    detailed: list[int] | None = None
    global_: Annotated[list[int] | None, Field(alias="global")] = None


class Overview(BaseModel):
    """
    Informações gerais do sistema RabbitMQ
    """

    model_config = ConfigDict(
        frozen=True,
    )
    churn_rates: ChurnRates
    cluster_name: str
    contexts: list[Context]
    erlang_full_version: str
    erlang_version: str
    exchange_types: list[ExchangeType]
    listeners: list[Listener]
    management_version: str
    message_stats: MessageStats
    node: str
    object_totals: ObjectTotals
    queue_totals: QueueTotals
    rabbitmq_version: str
    rates_mode: str
    sample_retention_policies: SampleRetentionPolicies
    statistics_db_event_queue: int


class ClusterName(BaseModel):
    """
    Nome do cluster
    """

    model_config = ConfigDict(
        frozen=True,
    )
    name: str


class Arguments(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    x_arg: Annotated[str | None, Field(alias="x-arg")] = None


class PublishInDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class PublishOutDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class MessageStats1(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    publish_in: int | None = None
    publish_in_details: PublishInDetails | None = None
    publish_out: int | None = None
    publish_out_details: PublishOutDetails | None = None


class Exchange(BaseModel):
    """
    Informações de uma exchange
    """

    model_config = ConfigDict(
        frozen=True,
    )
    arguments: Arguments
    auto_delete: bool
    durable: bool
    incoming: list[dict[str, Any]] | None = None
    internal: bool
    message_stats: MessageStats1
    name: str
    outgoing: list[dict[str, Any]] | None = None
    type: str
    user_who_performed_action: str
    vhost: str

    @field_validator("name", mode="after")
    @classmethod
    def validate_exchange_name(cls, v: str) -> str:
        if not v or len(v) > 255:
            raise ValueError("Exchange name must be 1-255 characters")
        if not re.match(r"^[a-zA-Z0-9._-]+$", v):
            raise ValueError(
                "Exchange name must contain only alphanumeric, underscore, dash, dot"
            )
        return v

    @field_validator("type", mode="after")
    @classmethod
    def validate_exchange_type(cls, v: str) -> str:
        valid_types = {"direct", "fanout", "topic", "headers"}
        if v not in valid_types:
            raise ValueError(f"Exchange type must be one of: {', '.join(valid_types)}")
        return v

    @field_validator("vhost", mode="after")
    @classmethod
    def validate_vhost(cls, v: str | None) -> str:
        if not v:
            return "/"
        if not re.match(r"^[a-zA-Z0-9/_-]+$", v):
            raise ValueError("Vhost must contain only URL-safe characters")
        return v

    @field_validator("durable", mode="after")
    @classmethod
    def validate_durable(cls, v: bool | None) -> bool:
        if v is None:
            return True
        if not isinstance(v, bool):
            raise TypeError("Durable must be a boolean")
        return v


class BackingQueueStatus(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    avg_ack_egress_rate: int | None = None
    avg_ack_ingress_rate: float | None = None
    avg_egress_rate: float | None = None
    avg_ingress_rate: float | None = None
    delta: list[str] | None = None
    len: int | None = None
    mode: str | None = None
    next_seq_id: int | None = None
    q1: int | None = None
    q2: int | None = None
    q3: int | None = None
    q4: int | None = None
    target_ram_count: str | None = None


class GarbageCollection(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    fullsweep_after: int | None = None
    max_heap_size: int | None = None
    min_bin_vheap_size: int | None = None
    min_heap_size: int | None = None
    minor_gcs: int | None = None


class MessageStats2(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    ack: int | None = None
    ack_details: AckDetails | None = None
    deliver: int | None = None
    deliver_details: DeliverDetails | None = None
    deliver_get: int | None = None
    deliver_get_details: DeliverGetDetails | None = None
    deliver_no_ack: int | None = None
    deliver_no_ack_details: DeliverNoAckDetails | None = None
    get: int | None = None
    get_details: GetDetails | None = None
    get_no_ack: int | None = None
    get_no_ack_details: GetNoAckDetails | None = None
    publish: int | None = None
    publish_details: PublishDetails | None = None
    redeliver: int | None = None
    redeliver_details: RedeliverDetails | None = None


class ReductionsDetails(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    rate: int | None = None


class Queue(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    arguments: Arguments | None = None
    auto_delete: bool | None = None
    backing_queue_status: BackingQueueStatus | None = None
    consumer_details: list[dict[str, Any]] | None = None
    consumer_utilisation: None = None
    consumers: int | None = None
    deliveries: list[dict[str, Any]] | None = None
    durable: bool | None = None
    effective_policy_definition: list[dict[str, Any]] | None = None
    exclusive: bool | None = None
    exclusive_consumer_tag: None = None
    garbage_collection: GarbageCollection | None = None
    head_message_timestamp: None = None
    idle_since: str | None = None
    incoming: list[dict[str, Any]] | None = None
    memory: int | None = None
    message_bytes: int | None = None
    message_bytes_paged_out: int | None = None
    message_bytes_persistent: int | None = None
    message_bytes_ram: int | None = None
    message_bytes_ready: int | None = None
    message_bytes_unacknowledged: int | None = None
    message_stats: MessageStats2 | None = None
    messages: int | None = None
    messages_details: MessagesDetails | None = None
    messages_paged_out: int | None = None
    messages_persistent: int | None = None
    messages_ram: int | None = None
    messages_ready: int | None = None
    messages_ready_details: MessagesReadyDetails | None = None
    messages_ready_ram: int | None = None
    messages_unacknowledged: int | None = None
    messages_unacknowledged_details: MessagesUnacknowledgedDetails | None = None
    messages_unacknowledged_ram: int | None = None
    name: str | None = None
    node: str | None = None
    operator_policy: None = None
    policy: None = None
    recoverable_slaves: None = None
    reductions: int | None = None
    reductions_details: ReductionsDetails | None = None
    state: str | None = None
    vhost: str | None = None

    @field_validator("name", mode="after")
    @classmethod
    def validate_queue_name(cls, v: str) -> str:
        if not v or len(v) > 255:
            raise ValueError("Queue name must be 1-255 characters")
        if not re.match(r"^[a-zA-Z0-9._-]+$", v):
            raise ValueError(
                "Queue name must contain only alphanumeric, underscore, dash, dot"
            )
        return v

    @field_validator("vhost", mode="after")
    @classmethod
    def validate_vhost(cls, v: str | None) -> str:
        if not v:
            return "/"
        if not re.match(r"^[a-zA-Z0-9/_-]+$", v):
            raise ValueError("Vhost must contain only URL-safe characters")
        return v

    @field_validator("durable", mode="after")
    @classmethod
    def validate_durable(cls, v: bool | None) -> bool:
        if v is None:
            return True
        if not isinstance(v, bool):
            raise TypeError("Durable must be a boolean")
        return v


class User(BaseModel):
    """
    Informações de um usuário
    """

    model_config = ConfigDict(
        frozen=True,
    )
    hashing_algorithm: str
    name: str
    password_hash: str
    tags: str


class WhoAmI(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    name: str | None = None
    tags: str | None = None


class Binding(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    arguments: Arguments | None = None
    destination: str | None = None
    destination_type: str | None = None
    properties_key: str | None = None
    routing_key: str | None = None
    source: str | None = None
    vhost: str | None = None


class Node(BaseModel):
    """
    Informações de um nó do cluster
    """

    model_config = ConfigDict(
        frozen=True,
    )
    name: str
    mem_used: int
    fd_used: int
    sockets_used: int


class MemoryBreakdown(RootModel[dict[str, int]]):
    model_config = ConfigDict(
        frozen=True,
    )
    root: dict[str, int]


class Connection(BaseModel):
    """
    Informações de uma conexão AMQP
    """

    model_config = ConfigDict(
        frozen=True,
    )
    name: str | None = None
    peer_host: str | None = None
    peer_port: int | None = None
    user: str | None = None


class PortListener(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    status: str
    port: int


class Definition(BaseModel):
    model_config = ConfigDict(
        frozen=True,
    )
    bindings: list[Binding] | None = None
    exchanges: list[Exchange] | None = None
    parameters: list[dict[str, Any]] | None = None
    policies: list[dict[str, Any]] | None = None
    queues: list[Queue] | None = None
    rabbit_version: str | None = None
