"""Configuration model for Azure Service Bus transport connections."""

from typing import Any

from pydantic import Field

from .baseconfig import BaseConfig


class AzureServiceBusConfig(BaseConfig):
    """
    Configuration model for Azure Service Bus.
    Inherits 'name' from BaseConfig.

    A configuration must specify EITHER a queue_name OR a topic_name
    (and optionally a subscription_name for topic consumption).

    Attributes:
        connection_string (str): The connection string for the Azure Service Bus namespace.
        queue_name (Optional[str]): The name of the queue to connect to.
                                     Required if not using a topic.
        topic_name (Optional[str]): The name of the topic to connect to.
                                    Required if not using a queue.
        subscription_name (Optional[str]): The name of the subscription for a topic.
                                           Required when consuming from a topic.
        prefetch_count (int): The number of messages to prefetch from the service bus.
                              Defaults to 0 (no prefetch).
        receive_mode (str): The message receive mode, either "PEEK_LOCK" or "RECEIVE_AND_DELETE".
                            Defaults to "PEEK_LOCK".
        client_properties (Dict[str, Any]): Additional properties for the Azure Service Bus client.
                                             Defaults to an empty dictionary.
    """

    connection_string: str
    queue_name: str | None = None
    topic_name: str | None = None
    subscription_name: str | None = None
    prefetch_count: int = 0
    receive_mode: str = "PEEK_LOCK"
    client_properties: dict[str, Any] = Field(default_factory=dict)
    message_properties: dict[str, Any] = Field(default_factory=dict)
