diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/aio/__init__.py b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/__init__.py similarity index 100% rename from sdk/servicebus/azure-servicebus/azure/servicebus/management/aio/__init__.py rename to sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/__init__.py diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/_management_client_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/_management_client_async.py new file mode 100644 index 000000000000..2a4f42505cbc --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/_management_client_async.py @@ -0,0 +1,875 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +import functools +from copy import copy +from typing import TYPE_CHECKING, Dict, Any, Union, List, cast, Tuple +from xml.etree.ElementTree import ElementTree, Element + +import six +from azure.core.async_paging import AsyncItemPaged +from azure.servicebus.aio.management._utils import extract_data_template, get_next_template +from azure.servicebus.management._model_workaround import avoid_timedelta_overflow +from msrest.exceptions import ValidationError +from azure.core.exceptions import raise_with_traceback, ResourceNotFoundError +from azure.core.pipeline import AsyncPipeline +from azure.core.pipeline.policies import HttpLoggingPolicy, DistributedTracingPolicy, ContentDecodePolicy, \ + RequestIdPolicy, AsyncBearerTokenCredentialPolicy +from azure.core.pipeline.transport import AioHttpTransport + +from ...management._generated.models import QueueDescriptionFeed, TopicDescriptionEntry, \ + QueueDescriptionEntry, SubscriptionDescriptionFeed, SubscriptionDescriptionEntry, RuleDescriptionEntry, \ + RuleDescriptionFeed, NamespacePropertiesEntry, CreateTopicBody, CreateTopicBodyContent, \ + TopicDescriptionFeed, CreateSubscriptionBody, CreateSubscriptionBodyContent, CreateRuleBody, \ + CreateRuleBodyContent, CreateQueueBody, CreateQueueBodyContent, \ + QueueDescription as InternalQueueDescription, TopicDescription as InternalTopicDescription, \ + SubscriptionDescription as InternalSubscriptionDescription, RuleDescription as InternalRuleDescription + +from ..._common.utils import parse_conn_str +from ..._common.constants import JWT_TOKEN_SCOPE +from ...aio._base_handler_async import ServiceBusSharedKeyCredential +from ...management._generated.aio._configuration_async import ServiceBusManagementClientConfiguration +from ...management._generated.aio._service_bus_management_client_async import ServiceBusManagementClient \ + as ServiceBusManagementClientImpl +from ...management import _constants as constants +from ._shared_key_policy_async import AsyncServiceBusSharedKeyCredentialPolicy +from ...management._models import QueueRuntimeInfo, QueueDescription, TopicDescription, TopicRuntimeInfo, \ + SubscriptionDescription, SubscriptionRuntimeInfo, RuleDescription +from ...management._xml_workaround_policy import ServiceBusXMLWorkaroundPolicy +from ...management._handle_response_error import _handle_response_error + + +if TYPE_CHECKING: + from azure.core.credentials_async import AsyncTokenCredential # pylint:disable=ungrouped-imports + + +class ServiceBusManagementClient: + """Use this client to create, update, list, and delete resources of a ServiceBus namespace. + + :param str fully_qualified_namespace: The fully qualified host name for the Service Bus namespace. + :param credential: To authenticate to manage the entities of the ServiceBus namespace. + :type credential: Union[TokenCredential, ServiceBusSharedKeyCredential] + """ + + def __init__(self, fully_qualified_namespace, credential, **kwargs): + # type: (str, Union[AsyncTokenCredential, ServiceBusSharedKeyCredential], Dict[str, Any]) -> None + + self.fully_qualified_namespace = fully_qualified_namespace + self._credential = credential + self._endpoint = "https://" + fully_qualified_namespace + self._config = ServiceBusManagementClientConfiguration(self._endpoint, **kwargs) + self._pipeline = self._build_pipeline() + self._impl = ServiceBusManagementClientImpl(endpoint=fully_qualified_namespace, pipeline=self._pipeline) + + async def __aenter__(self) -> "ServiceBusManagementClient": + await self._impl.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._impl.__aexit__(*exc_details) + + def _build_pipeline(self, **kwargs): # pylint: disable=no-self-use + transport = kwargs.get('transport') + policies = kwargs.get('policies') + credential_policy = \ + AsyncServiceBusSharedKeyCredentialPolicy(self._endpoint, self._credential, "Authorization") \ + if isinstance(self._credential, ServiceBusSharedKeyCredential) \ + else AsyncBearerTokenCredentialPolicy(self._credential, JWT_TOKEN_SCOPE) + if policies is None: # [] is a valid policy list + policies = [ + RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + ContentDecodePolicy(**kwargs), + ServiceBusXMLWorkaroundPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + credential_policy, + self._config.logging_policy, + DistributedTracingPolicy(**kwargs), + HttpLoggingPolicy(**kwargs), + ] + if not transport: + transport = AioHttpTransport(**kwargs) + return AsyncPipeline(transport, policies) + + @classmethod + def from_connection_string(cls, conn_str, **kwargs): + # type: (str, Any) -> ServiceBusManagementClient + """Create a client from connection string. + + :param str conn_str: The connection string of the Service Bus Namespace. + :rtype: ~azure.servicebus.management.aio.ServiceBusManagementClient + """ + endpoint, shared_access_key_name, shared_access_key, _ = parse_conn_str(conn_str) + if "//" in endpoint: + endpoint = endpoint[endpoint.index("//")+2:] + return cls(endpoint, ServiceBusSharedKeyCredential(shared_access_key_name, shared_access_key), **kwargs) + + async def _get_entity_element(self, entity_name, enrich=False, **kwargs): + # type: (str, bool, Any) -> ElementTree + + with _handle_response_error(): + element = cast( + ElementTree, + await self._impl.entity.get(entity_name, enrich=enrich, api_version=constants.API_VERSION, **kwargs) + ) + return element + + async def _get_subscription_element(self, topic_name, subscription_name, enrich=False, **kwargs): + # type: (str, str, bool, Any) -> ElementTree + + with _handle_response_error(): + element = cast( + ElementTree, + await self._impl.subscription.get(topic_name, subscription_name, enrich=enrich, api_version=constants.API_VERSION, **kwargs) + ) + return element + + async def _get_rule_element(self, topic_name, subscription_name, rule_name, **kwargs): + # type: (str, str, str, Any) -> ElementTree + + with _handle_response_error(): + element = cast( + ElementTree, + await self._impl.rule.get(topic_name, subscription_name, rule_name, enrich=False, api_version=constants.API_VERSION, **kwargs) + ) + return element + + async def get_queue(self, queue_name, **kwargs): + # type: (str, Any) -> QueueDescription + """Get a QueueDescription. + + :param str queue_name: The name of the queue. + :rtype: ~azure.servicebus.management.QueueDescription + """ + entry_ele = await self._get_entity_element(queue_name, **kwargs) + entry = QueueDescriptionEntry.deserialize(entry_ele) + if not entry.content: + raise ResourceNotFoundError("Queue '{}' does not exist".format(queue_name)) + queue_description = QueueDescription._from_internal_entity(entry.content.queue_description) + queue_description.name = queue_name + return queue_description + + async def get_queue_runtime_info(self, queue_name, **kwargs): + # type: (str, Any) -> QueueRuntimeInfo + """Get the runtime information of a queue. + + :param str queue_name: The name of the queue. + :rtype: ~azure.servicebus.management.QueueRuntimeInfo + """ + entry_ele = await self._get_entity_element(queue_name, **kwargs) + entry = QueueDescriptionEntry.deserialize(entry_ele) + if not entry.content: + raise ResourceNotFoundError("Queue {} does not exist".format(queue_name)) + runtime_info = QueueRuntimeInfo._from_internal_entity(entry.content.queue_description) + runtime_info.name = queue_name + return runtime_info + + async def create_queue(self, queue, **kwargs): + # type: (Union[str, QueueDescription], Any) -> QueueDescription + """Create a queue. + + :param queue: The queue name or a `QueueDescription` instance. When it's a str, it will be the name + of the created queue. Other properties of the created queue will have async default values decided by the + ServiceBus. Use a `QueueDescription` if you want to set queue properties other than the queue name. + :type queue: Union[str, ~azure.servicebus.management.QueueDescription] + :rtype: ~azure.servicebus.management.QueueDescription + """ + try: + queue_name = queue.name # type: ignore + to_create = queue._to_internal_entity() # type: ignore # pylint:disable=protected-access + except AttributeError: + queue_name = queue # type: ignore + to_create = InternalQueueDescription() # Use an empty queue description. + + create_entity_body = CreateQueueBody( + content=CreateQueueBodyContent( + queue_description=to_create, # type: ignore + ) + ) + request_body = create_entity_body.serialize(is_xml=True) + try: + with _handle_response_error(): + entry_ele = cast( + ElementTree, + await self._impl.entity.put( + queue_name, # type: ignore + request_body, api_version=constants.API_VERSION, **kwargs) + ) + except ValidationError: + # post-hoc try to give a somewhat-justifiable failure reason. + if isinstance(queue, (six.string_types, QueueDescription)): + raise_with_traceback( + ValueError, + message="queue must be a non-empty str or a QueueDescription with non-empty str name") + raise_with_traceback( + TypeError, + message="queue must be a non-empty str or a QueueDescription with non-empty str name") + + entry = QueueDescriptionEntry.deserialize(entry_ele) + result = QueueDescription._from_internal_entity(entry.content.queue_description) + result.name = queue_name + return result + + async def update_queue(self, queue_description, **kwargs): + # type: (QueueDescription, Any) -> None + """Update a queue. + + :param queue_description: The properties of this `QueueDescription` will be applied to the queue in + ServiceBus. Only a portion of properties can be updated. + Refer to https://docs.microsoft.com/en-us/rest/api/servicebus/update-queue. + :type queue_description: ~azure.servicebus.management.QueueDescription + :keyword timedelta async default_message_time_to_live + :keyword timedelta lock_duration + :keyword bool dead_lettering_on_message_expiration + :keyword timedelta duplicate_detection_history_time_window + :keyword int max_delivery_count + :rtype: ~azure.servicebus.management.QueueDescription + """ + + # TODO: validate whether a queue_description has enough information + + if not isinstance(queue_description, QueueDescription): + raise TypeError("queue_description must be of type QueueDescription") + + internal_description = queue_description._to_internal_entity() + to_update = copy(internal_description) # pylint:disable=protected-access + + to_update.default_message_time_to_live = kwargs.get( + "async default_message_time_to_live") or queue_description.default_message_time_to_live + to_update.lock_duration = kwargs.get("lock_duration") or queue_description.lock_duration + to_update.dead_lettering_on_message_expiration = kwargs.get( + "dead_lettering_on_message_expiration") or queue_description.dead_lettering_on_message_expiration + to_update.duplicate_detection_history_time_window = kwargs.get( + "duplicate_detection_history_time_window") or queue_description.duplicate_detection_history_time_window + to_update.max_delivery_count = kwargs.get("max_delivery_count") or queue_description.max_delivery_count + + to_update.default_message_time_to_live = avoid_timedelta_overflow(to_update.default_message_time_to_live) + to_update.auto_delete_on_idle = avoid_timedelta_overflow(to_update.auto_delete_on_idle) + + create_entity_body = CreateQueueBody( + content=CreateQueueBodyContent( + queue_description=to_update, + ) + ) + request_body = create_entity_body.serialize(is_xml=True) + with _handle_response_error(): + try: + await self._impl.entity.put( + queue_description.name, # type: ignore + request_body, + api_version=constants.API_VERSION, + if_match="*", + **kwargs + ) + except ValidationError: + # post-hoc try to give a somewhat-justifiable failure reason. + raise_with_traceback( + ValueError, + message="queue_description must be a QueueDescription with valid fields, " + "including non-empty string name") + + async def delete_queue(self, queue, **kwargs): + # type: (Union[str, QueueDescription], Any) -> None + """Delete a queue. + + :param Union[str, azure.servicebus.management.QueueDescription] queue: The name of the queue. + :rtype: None + """ + try: + queue_name = queue.name + except AttributeError: + queue_name = queue + if not queue_name: + raise ValueError("queue_name must not be None or empty") + with _handle_response_error(): + await self._impl.entity.delete(queue_name, api_version=constants.API_VERSION, **kwargs) + + def list_queues(self, **kwargs): + # type: (Any) -> AsyncItemPaged[QueueDescription] + """List the queues of a ServiceBus namespace. + + :keyword int start_index: skip this number of queues. + :keyword int max_page_size: return at most this number of queues if there are more than this number in + the ServiceBus namespace. + :rtype: ItemPaged[~azure.servicebus.management.QueueDescription] + """ + + def entry_to_qd(entry): + qd = QueueDescription._from_internal_entity(entry.content.queue_description) + qd.name = entry.title + return qd + + extract_data = functools.partial( + extract_data_template, QueueDescriptionFeed, entry_to_qd + ) + get_next = functools.partial( + get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_QUEUES), **kwargs + ) + return AsyncItemPaged( + get_next, extract_data) + + def list_queues_runtime_info(self, **kwargs): + # type: (Any) -> AsyncItemPaged[QueueRuntimeInfo] + """List the runtime info of the queues in a ServiceBus namespace. + + :keyword int start_index: skip this number of queues. + :keyword int max_page_size: return at most this number of queues if there are more than this number in + the ServiceBus namespace. + :rtype: ItemPaged[~azure.servicebus.management.QueueRuntimeInfo] + """ + + def entry_to_qr(entry): + qd = QueueRuntimeInfo._from_internal_entity(entry.content.queue_description) + qd.name = entry.title + return qd + + extract_data = functools.partial( + extract_data_template, QueueDescriptionFeed, entry_to_qr + ) + get_next = functools.partial( + get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_QUEUES), **kwargs + ) + return AsyncItemPaged( + get_next, extract_data) + + async def get_topic(self, topic_name, **kwargs): + # type: (str, Any) -> TopicDescription + """Get a TopicDescription. + + :param str topic_name: The name of the queue. + :rtype: ~azure.servicebus.management.TopicDescription + """ + entry_ele = await self._get_entity_element(topic_name, **kwargs) + entry = TopicDescriptionEntry.deserialize(entry_ele) + if not entry.content: + raise ResourceNotFoundError("Topic '{}' does not exist".format(topic_name)) + topic_description = TopicDescription._from_internal_entity(entry.content.topic_description) + topic_description.name = topic_name + return topic_description + + async def get_topic_runtime_info(self, topic_name, **kwargs): + # type: (str, Any) -> TopicRuntimeInfo + """Get a TopicRuntimeInfo + + :param str topic_name: + :rtype: ~azure.servicebus.management.TopicRuntimeInfo + """ + entry_ele = await self._get_entity_element(topic_name, **kwargs) + entry = TopicDescriptionEntry.deserialize(entry_ele) + if not entry.content: + raise ResourceNotFoundError("Topic {} does not exist".format(topic_name)) + topic_description = TopicRuntimeInfo._from_internal_entity(entry.content.topic_description) + topic_description.name = topic_name + return topic_description + + async def create_topic(self, topic, **kwargs): + # type: (Union[str, TopicDescription], Any) -> TopicDescription + """ + + :param Union[str, ~azure.servicebus.management.TopicDescription] topic: + :rtype: ~azure.servicebus.management.TopicDescription + """ + try: + topic_name = topic.name # type: ignore + to_create = topic._to_internal_entity() # type: ignore # pylint:disable=protected-access + except AttributeError as e: + topic_name = topic # type: ignore + to_create = InternalTopicDescription() # Use an empty topic description. + + create_entity_body = CreateTopicBody( + content=CreateTopicBodyContent( + topic_description=to_create, # type: ignore + ) + ) + request_body = create_entity_body.serialize(is_xml=True) + try: + with _handle_response_error(): + entry_ele = cast( + ElementTree, + await self._impl.entity.put( + topic_name, # type: ignore + request_body, api_version=constants.API_VERSION, **kwargs) + ) + except ValidationError as e: + # post-hoc try to give a somewhat-justifiable failure reason. + if isinstance(topic, (six.string_types, TopicDescription)): + raise_with_traceback( + ValueError, + message="topic must be a non-empty str or a QueueDescription with non-empty str name") + raise_with_traceback( + TypeError, + message="topic must be a non-empty str or a QueueDescription with non-empty str name") + + entry = TopicDescriptionEntry.deserialize(entry_ele) + result = TopicDescription._from_internal_entity(entry.content.topic_description) + result.name = topic_name + return result + + async def update_topic(self, topic_description, **kwargs): + # type: (TopicDescription, Any) -> None + """ + + :param ~azure.servicebus.management.TopicDescription topic_description: + :keyword timedelta async default_message_time_to_live: + :keyword timedelta duplicate_detection_history_time_window: + :rtype: None + """ + + # TODO: validate whether topic_description has enough information (refer to the create_topic response) + if not isinstance(topic_description, TopicDescription): + raise TypeError("topic_description must be of type TopicDescription") + + internal_description = topic_description._to_internal_entity() + to_update = copy(internal_description) # pylint:disable=protected-access + + to_update.default_message_time_to_live = kwargs.get("async default_message_time_to_live") or topic_description.default_message_time_to_live + to_update.duplicate_detection_history_time_window = kwargs.get("duplicate_detection_history_time_window") or topic_description.duplicate_detection_history_time_window + + to_update.default_message_time_to_live = avoid_timedelta_overflow(to_update.default_message_time_to_live) + to_update.auto_delete_on_idle = avoid_timedelta_overflow(to_update.auto_delete_on_idle) + + create_entity_body = CreateTopicBody( + content=CreateTopicBodyContent( + topic_description=to_update, + ) + ) + request_body = create_entity_body.serialize(is_xml=True) + with _handle_response_error(): + try: + await self._impl.entity.put( + topic_description.name, # type: ignore + request_body, + api_version=constants.API_VERSION, + if_match="*", + **kwargs + ) + except ValidationError: + # post-hoc try to give a somewhat-justifiable failure reason. + raise_with_traceback( + ValueError, + message="topic_description must be a TopicDescription with valid fields, " + "including non-empty string topic name") + + async def delete_topic(self, topic, **kwargs): + # type: (Union[str, TopicDescription], Any) -> None + """ + + :param Union[str, TopicDescription] topic: + :rtype: None + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + await self._impl.entity.delete(topic_name, api_version=constants.API_VERSION, **kwargs) + + def list_topics(self, **kwargs): + # type: (Any) -> ItemPaged[TopicDescription] + """ + :keyword int start_index: skip this number of queues. + :keyword int max_page_size: return at most this number of queues if there are more than this number in + the ServiceBus namespace. + :rtype: ItemPaged[~azure.servicebus.management.TopicDescription] + """ + def entry_to_topic(entry): + topic = TopicDescription._from_internal_entity(entry.content.topic_description) + topic.name = entry.title + return topic + + extract_data = functools.partial( + extract_data_template, TopicDescriptionFeed, entry_to_topic + ) + get_next = functools.partial( + get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_TOPICS), **kwargs + ) + return AsyncItemPaged( + get_next, extract_data) + + def list_topics_runtime_info(self, **kwargs): + # type: (Any) -> ItemPaged[TopicRuntimeInfo] + """ + :keyword int start_index: skip this number of queues. + :keyword int max_page_size: return at most this number of queues if there are more than this number in + the ServiceBus namespace. + :rtype: ItemPaged[~azure.servicebus.management.TopicRuntimeInfo] + """ + def entry_to_topic(entry): + topic = TopicRuntimeInfo._from_internal_entity(entry.content.topic_description) + topic.name = entry.title + return topic + + extract_data = functools.partial( + extract_data_template, TopicDescriptionFeed, entry_to_topic + ) + get_next = functools.partial( + get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_TOPICS), **kwargs + ) + return AsyncItemPaged( + get_next, extract_data) + + async def get_subscription(self, topic, subscription_name, **kwargs): + # type: (Union[str, TopicDescription], str, Any) -> SubscriptionDescription + """ + + :param Union[str, TopicDescription] topic: + :param str subscription_name: + :rtype: ~azure.servicebus.management.SubscriptionDescription + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + entry_ele = self._get_subscription_element(topic_name, subscription_name, **kwargs) + entry = SubscriptionDescriptionEntry.deserialize(entry_ele) + if not entry.content: + raise ResourceNotFoundError( + "Subscription('Topic: {}, Subscription: {}') does not exist".format(subscription_name, topic_name)) + subscription = SubscriptionDescription._from_internal_entity(entry.content.subscription_description) + subscription.name = entry.title + return subscription + + async def get_subscription_runtime_info(self, topic, subscription_name, **kwargs): + # type: (Union[str, TopicDescription], str, Any) -> SubscriptionRuntimeInfo + """ + + :param Union[str, TopicDescription] topic: + :param str subscription_name: + :rtype: ~azure.servicebus.management.SubscriptionRuntimeInfo + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + entry_ele = self._get_subscription_element(topic_name, subscription_name, **kwargs) + entry = SubscriptionDescriptionEntry.deserialize(entry_ele) + if not entry.content: + raise ResourceNotFoundError( + "Subscription('Topic: {}, Subscription: {}') does not exist".format(subscription_name, topic_name)) + subscription = SubscriptionRuntimeInfo._from_internal_entity(entry.content.subscription_description) + subscription.name = entry.title + return subscription + + async def create_subscription(self, topic, subscription, **kwargs): + """ + + :param Union[str, TopicDescription] topic: + :param Union[str, ~azure.servicebus.management.SubscriptionDescription] subscription: + :rtype: ~azure.servicebus.management.SubscriptionDescription + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + try: + subscription_name = subscription.name # type: ignore + to_create = subscription._to_internal_entity() # type: ignore # pylint:disable=protected-access + except AttributeError: + subscription_name = subscription # type: ignore + to_create = InternalSubscriptionDescription() # Use an empty queue description. + + create_entity_body = CreateSubscriptionBody( + content=CreateSubscriptionBodyContent( + subscription_description=to_create, # type: ignore + ) + ) + request_body = create_entity_body.serialize(is_xml=True) + try: + with _handle_response_error(): + entry_ele = cast( + ElementTree, + await self._impl.subscription.put( + topic_name, + subscription_name, # type: ignore + request_body, api_version=constants.API_VERSION, **kwargs) + ) + except ValidationError: + # post-hoc try to give a somewhat-justifiable failure reason. + # TODO: validate param topic + if isinstance(subscription, (six.string_types, SubscriptionDescription)): + raise_with_traceback( + ValueError, + message="subscription must be a non-empty str or a SubscriptionDescription with non-empty str name") + raise_with_traceback( + TypeError, + message="subscription must be a non-empty str or a SubscriptionDescription with non-empty str name") + + entry = SubscriptionDescriptionEntry.deserialize(entry_ele) + result = SubscriptionDescription._from_internal_entity(entry.content.subscription_description) + result.name = subscription_name + return result + + async def update_subscription(self, topic, subscription_description, **kwargs): + """ + + :param Union[str, TopicDescription] topic: + :param ~azure.servicebus.management.SubscriptionDescription subscription: + :rtype: None + """ + # TODO: validate param topic and whether subscription_description has enough properties. + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + if not isinstance(subscription_description, SubscriptionDescription): + raise TypeError("subscription_description must be of type SubscriptionDescription") + + internal_description = subscription_description._to_internal_entity() + to_update = copy(internal_description) # pylint:disable=protected-access + + to_update.default_message_time_to_live = avoid_timedelta_overflow(to_update.default_message_time_to_live) + to_update.auto_delete_on_idle = avoid_timedelta_overflow(to_update.auto_delete_on_idle) + + create_entity_body = CreateTopicBody( + content=CreateTopicBodyContent( + topic_description=to_update, + ) + ) + request_body = create_entity_body.serialize(is_xml=True) + with _handle_response_error(): + await self._impl.subscription.put( + topic_name, + subscription_description.name, + request_body, + api_version=constants.API_VERSION, + if_match="*", + **kwargs + ) + + async def delete_subscription(self, topic, subscription, **kwargs): + """ + :param Union[str, TopicDescription] topic: + :param Union[str, SubscriptionDescription] subscription: + :rtype: None + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + try: + subscription_name = subscription.name + except AttributeError: + subscription_name = subscription + await self._impl.subscription.delete(topic_name, subscription_name, api_version=constants.API_VERSION, **kwargs) + + def list_subscriptions(self, topic, **kwargs): + """List the subscriptions of a ServiceBus Topic. + + :param Union[str, ~azure.servicebus.management.TopicDescription] topic: + :keyword int start_index: skip this number of queues. + :keyword int max_page_size: return at most this number of subscriptions if there are more than this number in + the ServiceBus Topic. + :rtype: ItemPaged[~azure.servicebus.management.SubscriptionDescription] + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + + def entry_to_subscription(entry): + subscription = SubscriptionDescription._from_internal_entity(entry.content.subscription_description) + subscription.name = entry.title + return subscription + + extract_data = functools.partial( + extract_data_template, SubscriptionDescriptionFeed, entry_to_subscription + ) + get_next = functools.partial( + get_next_template, functools.partial(self._impl.list_subscriptions, topic_name), **kwargs + ) + return AsyncItemPaged( + get_next, extract_data) + + def list_subscriptions_runtime_info(self, topic, **kwargs): + """List the subscriptions of a ServiceBus Topic Runtime Information. + + :param Union[str, TopicDescription] topic: + :keyword int start_index: skip this number of queues. + :keyword int max_page_size: return at most this number of subscriptions if there are more than this number in + the ServiceBus Topic. + :rtype: ItemPaged[~azure.servicebus.management.SubscriptionRuntimeInfo] + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + + def entry_to_subscription(entry): + subscription = SubscriptionRuntimeInfo._from_internal_entity(entry.content.subscription_description) + subscription.name = entry.title + return subscription + + extract_data = functools.partial( + extract_data_template, SubscriptionDescriptionFeed, entry_to_subscription + ) + get_next = functools.partial( + get_next_template, functools.partial(self._impl.list_subscriptions, topic_name), **kwargs + ) + return AsyncItemPaged( + get_next, extract_data) + + async def get_rule(self, topic, subscription, rule_name, **kwargs): + """ + + :param Union[str, TopicDescription] topic: + :param Union[str, SubscriptionDescription] subscription: + :param str rule_name: + :rtype: ~azure.servicebus.management.RuleDescription + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + try: + subscription_name = subscription.name + except AttributeError: + subscription_name = subscription + entry_ele = self._get_rule_element(topic_name, subscription_name, rule_name, **kwargs) + entry = RuleDescriptionEntry.deserialize(entry_ele) + if not entry.content: + raise ResourceNotFoundError( + "Rule('Topic: {}, Subscription: {}, Rule {}') does not exist".format(subscription_name, topic_name, rule_name)) + rule_description = RuleDescription._from_internal_entity(entry.content.rule_description) + return rule_description + + async def create_rule(self, topic, subscription, rule, **kwargs): + """ + :param Union[str, TopicDescription] topic: + :param Union[str, SubscriptionDescription] subscription: + :param Union[str, ~azure.servicebus.management.RuleDescription] rule: + :rtype: ~azure.servicebus.management.RuleDescription + """ + # TODO: validate param topic, subscription and rule. + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + try: + subscription_name = subscription.name + except AttributeError: + subscription_name = subscription + try: + rule_name = rule.name + to_create = rule._to_internal_entity() # type: ignore # pylint:disable=protected-access + except AttributeError: + rule_name = rule + to_create = InternalRuleDescription() # Use an empty queue description. + + create_entity_body = CreateRuleBody( + content=CreateRuleBodyContent( + rule_description=to_create, # type: ignore + ) + ) + request_body = create_entity_body.serialize(is_xml=True) + with _handle_response_error(): + entry_ele = await self._impl.rule.put( + topic_name, + subscription_name, # type: ignore + rule_name, + request_body, api_version=constants.API_VERSION, **kwargs) + entry = RuleDescriptionEntry.deserialize(entry_ele) + result = entry.content.rule_description + return result + + async def update_rule(self, topic, subscription, rule_description, **kwargs): + """ + + :param Union[str, TopicDescription] topic: + :param Union[str, SubscriptionDescription] subscription: + :param ~azure.servicebus.management.RuleDescription rule_description: + :rtype: None + """ + # TODO: validate param topic, subscription and rule_description. + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + try: + subscription_name = subscription.name + except AttributeError: + subscription_name = subscription + + internal_description = rule_description._to_internal_entity() + to_update = copy(internal_description) # pylint:disable=protected-access + + create_entity_body = CreateRuleBody( + content=CreateRuleBodyContent( + rule_description=to_update, + ) + ) + request_body = create_entity_body.serialize(is_xml=True) + with _handle_response_error(): + await self._impl.rule.put( + topic_name, + subscription_name, + rule_description.name, + request_body, + api_version=constants.API_VERSION, + if_match="*", + **kwargs + ) + + async def delete_rule(self, topic, subscription, rule, **kwargs): + """ + + :param Union[str, TopicDescription] topic: + :param Union[str, SubscriptionDescription] subscription: + :param Union[str, RuleDescription] subscription: + :rtype: None + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + try: + subscription_name = subscription.name + except AttributeError: + subscription_name = subscription + try: + rule_name = rule.name + except AttributeError: + rule_name = rule + await self._impl.rule.delete(topic_name, subscription_name, rule_name, api_version=constants.API_VERSION, **kwargs) + + def list_rules(self, topic, subscription, **kwargs): + """ + + :param Union[str, TopicDescription] topic: + :param Union[str, SubscriptionDescription] subscription: + :keyword int start_index: + :keyword int max_page_size: + :rtype: ItemPaged[~azure.servicebus.management.RuleDescription] + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + try: + subscription_name = subscription.name + except AttributeError: + subscription_name = subscription + + def entry_to_rule(entry): + rule = entry.content.rule_description + return RuleDescription._from_internal_entity(rule) + + extract_data = functools.partial( + extract_data_template, RuleDescriptionFeed, entry_to_rule + ) + get_next = functools.partial( + get_next_template, functools.partial(self._impl.list_rules, topic_name, subscription_name), **kwargs + ) + return AsyncItemPaged( + get_next, extract_data) + + async def get_namespace_properties(self, **kwargs): + """ + + :rtype: NamespaceProperties + """ + entry_el = await self._impl.namespace.get(api_version=constants.API_VERSION, **kwargs) + namespace_entry = NamespacePropertiesEntry.deserialize(entry_el) + return namespace_entry.content.namespace_properties diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/aio/_shared_key_policy_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/_shared_key_policy_async.py similarity index 100% rename from sdk/servicebus/azure-servicebus/azure/servicebus/management/aio/_shared_key_policy_async.py rename to sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/_shared_key_policy_async.py diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/_utils.py b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/_utils.py new file mode 100644 index 000000000000..03667b090565 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/_utils.py @@ -0,0 +1,46 @@ +from typing import cast, Union +from xml.etree.ElementTree import ElementTree + + +try: + import urllib.parse as urlparse +except ImportError: + import urlparse # python 2.7 + +from azure.servicebus.management import _constants as constants +from ...management._handle_response_error import _handle_response_error + + +async def extract_data_template(feed_class, convert, feed_element): + deserialized = feed_class.deserialize(feed_element) + list_of_qd = [convert(x) if convert else x for x in deserialized.entry] + next_link = None + if deserialized.link and len(deserialized.link) == 2: + next_link = deserialized.link[1].href + return next_link, iter(list_of_qd) + + +async def get_next_template(list_func, *args, **kwargs): + if len(args) > 0: + next_link = args[0] + else: + next_link = kwargs.pop("next_link") + + start_index = kwargs.pop("start_index", 0) + max_page_size = kwargs.pop("max_page_size", 100) + api_version = constants.API_VERSION + if next_link: + queries = urlparse.parse_qs(urlparse.urlparse(next_link).query) + start_index = int(queries['$skip'][0]) + max_page_size = int(queries['$top'][0]) + api_version = queries['api-version'][0] + with _handle_response_error(): + feed_element = cast( + ElementTree, + await list_func( + skip=start_index, top=max_page_size, + api_version=api_version, + **kwargs + ) + ) + return feed_element diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/__init__.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/__init__.py index 43f52de5584f..b6941307ef95 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/__init__.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/__init__.py @@ -5,16 +5,29 @@ from ._management_client import ServiceBusManagementClient from ._generated.models import AuthorizationRule, MessageCountDetails, \ - AccessRights, EntityAvailabilityStatus, EntityStatus -from ._models import QueueRuntimeInfo, QueueDescription + AccessRights, EntityAvailabilityStatus, EntityStatus, \ + NamespaceProperties, MessagingSku, NamespaceType + +from ._models import QueueRuntimeInfo, QueueDescription, TopicRuntimeInfo, TopicDescription, \ + SubscriptionDescription, SubscriptionRuntimeInfo, RuleDescription, \ + TrueRuleFilter, FalseRuleFilter, SqlRuleFilter, CorrelationRuleFilter, \ + SqlRuleAction __all__ = [ - "ServiceBusManagementClient", + 'ServiceBusManagementClient', 'AuthorizationRule', 'MessageCountDetails', 'QueueDescription', 'QueueRuntimeInfo', + 'TopicDescription', + 'TopicRuntimeInfo', + 'SubscriptionDescription', + 'SubscriptionRuntimeInfo', 'AccessRights', 'EntityAvailabilityStatus', 'EntityStatus', + 'RuleDescription', + 'CorrelationRuleFilter', 'SqlRuleFilter', 'TrueRuleFilter', 'FalseRuleFilter', + 'SqlRuleAction', + 'NamespaceProperties', 'MessagingSku', 'NamespaceType', ] diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_constants.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_constants.py index 6a999075700b..d1a73b6cfc14 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_constants.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_constants.py @@ -11,3 +11,4 @@ TITLE_TAG = "{http://www.w3.org/2005/Atom}title" ENTITY_TYPE_QUEUES = "queues" +ENTITY_TYPE_TOPICS = "topics" diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_service_bus_management_client.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_service_bus_management_client.py index 696101eed03d..ee7515cab3ce 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_service_bus_management_client.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_service_bus_management_client.py @@ -16,16 +16,25 @@ from typing import Any, Optional from ._configuration import ServiceBusManagementClientConfiguration -from .operations import QueueOperations +from .operations import EntityOperations from .operations import ServiceBusManagementClientOperationsMixin +from .operations import SubscriptionOperations +from .operations import RuleOperations +from .operations import NamespaceOperations from . import models class ServiceBusManagementClient(ServiceBusManagementClientOperationsMixin): """Azure Service Bus client for managing Queues, Topics, and Subscriptions. - :ivar queue: QueueOperations operations - :vartype queue: azure.servicebus.management._generated.operations.QueueOperations + :ivar entity: EntityOperations operations + :vartype entity: azure.servicebus.management._generated.operations.EntityOperations + :ivar subscription: SubscriptionOperations operations + :vartype subscription: azure.servicebus.management._generated.operations.SubscriptionOperations + :ivar rule: RuleOperations operations + :vartype rule: azure.servicebus.management._generated.operations.RuleOperations + :ivar namespace: NamespaceOperations operations + :vartype namespace: azure.servicebus.management._generated.operations.NamespaceOperations :param endpoint: The Service Bus fully qualified domain name. :type endpoint: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -45,7 +54,13 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.queue = QueueOperations( + self.entity = EntityOperations( + self._client, self._config, self._serialize, self._deserialize) + self.subscription = SubscriptionOperations( + self._client, self._config, self._serialize, self._deserialize) + self.rule = RuleOperations( + self._client, self._config, self._serialize, self._deserialize) + self.namespace = NamespaceOperations( self._client, self._config, self._serialize, self._deserialize) def close(self): diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_service_bus_management_client_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_service_bus_management_client_async.py index 74270b317f0f..196e6e457645 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_service_bus_management_client_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_service_bus_management_client_async.py @@ -12,16 +12,25 @@ from msrest import Deserializer, Serializer from ._configuration_async import ServiceBusManagementClientConfiguration -from .operations_async import QueueOperations +from .operations_async import EntityOperations from .operations_async import ServiceBusManagementClientOperationsMixin +from .operations_async import SubscriptionOperations +from .operations_async import RuleOperations +from .operations_async import NamespaceOperations from .. import models class ServiceBusManagementClient(ServiceBusManagementClientOperationsMixin): """Azure Service Bus client for managing Queues, Topics, and Subscriptions. - :ivar queue: QueueOperations operations - :vartype queue: azure.servicebus.management._generated.aio.operations_async.QueueOperations + :ivar entity: EntityOperations operations + :vartype entity: azure.servicebus.management._generated.aio.operations_async.EntityOperations + :ivar subscription: SubscriptionOperations operations + :vartype subscription: azure.servicebus.management._generated.aio.operations_async.SubscriptionOperations + :ivar rule: RuleOperations operations + :vartype rule: azure.servicebus.management._generated.aio.operations_async.RuleOperations + :ivar namespace: NamespaceOperations operations + :vartype namespace: azure.servicebus.management._generated.aio.operations_async.NamespaceOperations :param endpoint: The Service Bus fully qualified domain name. :type endpoint: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -40,7 +49,13 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.queue = QueueOperations( + self.entity = EntityOperations( + self._client, self._config, self._serialize, self._deserialize) + self.subscription = SubscriptionOperations( + self._client, self._config, self._serialize, self._deserialize) + self.rule = RuleOperations( + self._client, self._config, self._serialize, self._deserialize) + self.namespace = NamespaceOperations( self._client, self._config, self._serialize, self._deserialize) async def close(self) -> None: diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/__init__.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/__init__.py index 98a8b77c8e0a..04ebe619db3e 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/__init__.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/__init__.py @@ -6,10 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._queue_operations_async import QueueOperations +from ._entity_operations_async import EntityOperations from ._service_bus_management_client_operations_async import ServiceBusManagementClientOperationsMixin +from ._subscription_operations_async import SubscriptionOperations +from ._rule_operations_async import RuleOperations +from ._namespace_operations_async import NamespaceOperations __all__ = [ - 'QueueOperations', + 'EntityOperations', 'ServiceBusManagementClientOperationsMixin', + 'SubscriptionOperations', + 'RuleOperations', + 'NamespaceOperations', ] diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_queue_operations_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_entity_operations_async.py similarity index 87% rename from sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_queue_operations_async.py rename to sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_entity_operations_async.py index 06ab52c352e0..8eacacacd5de 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_queue_operations_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_entity_operations_async.py @@ -17,8 +17,8 @@ T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class QueueOperations: - """QueueOperations async operations. +class EntityOperations: + """EntityOperations async operations. You should not instantiate this class directly. Instead, you should create a Client instance that instantiates it for you and attaches it as an attribute. @@ -41,17 +41,17 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get( self, - queue_name: str, + entity_name: str, enrich: Optional[bool] = False, api_version: Optional[str] = "2017_04", **kwargs ) -> object: - """Get the details about the Queue with the given queueName. + """Get the details about the Queue or Topic with the given entityName. - Get Queue. + Get Queue or Topic. - :param queue_name: The name of the queue relative to the Service Bus namespace. - :type queue_name: str + :param entity_name: The name of the queue or topic relative to the Service Bus namespace. + :type entity_name: str :param enrich: A query parameter that sets enrich to true or false. :type enrich: bool :param api_version: Api Version. @@ -69,7 +69,7 @@ async def get( url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), + 'entityName': self._serialize.url("entity_name", entity_name, 'str', min_length=1), } url = self._client.format_url(url, **path_format_arguments) @@ -100,21 +100,21 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{queueName}'} # type: ignore + get.metadata = {'url': '/{entityName}'} # type: ignore async def put( self, - queue_name: str, + entity_name: str, request_body: object, api_version: Optional[str] = "2017_04", if_match: Optional[str] = None, **kwargs ) -> object: - """Create or update a queue at the provided queuePath. + """Create or update a queue or topic at the provided entityName. - :param queue_name: The name of the queue relative to the Service Bus namespace. - :type queue_name: str - :param request_body: Parameters required to make or edit a queue. + :param entity_name: The name of the queue or topic relative to the Service Bus namespace. + :type entity_name: str + :param request_body: Parameters required to make or edit a queue or topic. :type request_body: object :param api_version: Api Version. :type api_version: str @@ -131,13 +131,13 @@ async def put( cls = kwargs.pop('cls', None) # type: ClsType[object] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/xml") + content_type = kwargs.pop("content_type", "application/atom+xml") # Construct URL url = self.put.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), + 'entityName': self._serialize.url("entity_name", entity_name, 'str', min_length=1), } url = self._client.format_url(url, **path_format_arguments) @@ -178,20 +178,20 @@ async def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/{queueName}'} # type: ignore + put.metadata = {'url': '/{entityName}'} # type: ignore async def delete( self, - queue_name: str, + entity_name: str, api_version: Optional[str] = "2017_04", **kwargs ) -> object: - """Delete the Queue with the given queueName. + """Delete the Queue or Topic with the given entityName. - Delete Queue. + Delete Queue or Topic. - :param queue_name: The name of the queue relative to the Service Bus namespace. - :type queue_name: str + :param entity_name: The name of the queue or topic relative to the Service Bus namespace. + :type entity_name: str :param api_version: Api Version. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -207,7 +207,7 @@ async def delete( url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), + 'entityName': self._serialize.url("entity_name", entity_name, 'str', min_length=1), } url = self._client.format_url(url, **path_format_arguments) @@ -236,4 +236,4 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{queueName}'} # type: ignore + delete.metadata = {'url': '/{entityName}'} # type: ignore diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_namespace_operations_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_namespace_operations_async.py new file mode 100644 index 000000000000..d8fa5d686223 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_namespace_operations_async.py @@ -0,0 +1,94 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class NamespaceOperations: + """NamespaceOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.servicebus.management._generated.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + api_version: Optional[str] = "2017_04", + **kwargs + ) -> "models.NamespacePropertiesEntry": + """Get the details about the Service Bus namespace. + + Get Namespace Properties. + + :param api_version: Api Version. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NamespacePropertiesEntry, or the result of cls(response) + :rtype: ~azure.servicebus.management._generated.models.NamespacePropertiesEntry + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.NamespacePropertiesEntry"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('NamespacePropertiesEntry', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/$namespaceinfo'} # type: ignore diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_rule_operations_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_rule_operations_async.py new file mode 100644 index 000000000000..5e00dba3c5c4 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_rule_operations_async.py @@ -0,0 +1,263 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RuleOperations: + """RuleOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.servicebus.management._generated.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + topic_name: str, + subscription_name: str, + rule_name: str, + enrich: Optional[bool] = False, + api_version: Optional[str] = "2017_04", + **kwargs + ) -> object: + """Get the details about the rule of a subscription of a topic. + + Get Rule. + + :param topic_name: name of the topic. + :type topic_name: str + :param subscription_name: name of the subscription. + :type subscription_name: str + :param rule_name: name of the filter. + :type rule_name: str + :param enrich: A query parameter that sets enrich to true or false. + :type enrich: bool + :param api_version: Api Version. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', min_length=1), + 'ruleName': self._serialize.url("rule_name", rule_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if enrich is not None: + query_parameters['enrich'] = self._serialize.query("enrich", enrich, 'bool') + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + + async def put( + self, + topic_name: str, + subscription_name: str, + rule_name: str, + request_body: object, + api_version: Optional[str] = "2017_04", + if_match: Optional[str] = None, + **kwargs + ) -> object: + """Create or update a rule. + + :param topic_name: name of the topic. + :type topic_name: str + :param subscription_name: name of the subscription. + :type subscription_name: str + :param rule_name: name of the filter. + :type rule_name: str + :param request_body: Parameters required to make or edit a rule. + :type request_body: object + :param api_version: Api Version. + :type api_version: str + :param if_match: Match condition for an entity to be updated. If specified and a matching + entity is not found, an error will be raised. To force an unconditional update, set to the + wildcard character (*). If not specified, an insert will be performed when no existing entity + is found to update and a replace will be performed if an existing entity is found. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/atom+xml") + + # Construct URL + url = self.put.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', min_length=1), + 'ruleName': self._serialize.url("rule_name", rule_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(request_body, 'object', is_xml=True) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + put.metadata = {'url': '/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + + async def delete( + self, + topic_name: str, + subscription_name: str, + rule_name: str, + api_version: Optional[str] = "2017_04", + **kwargs + ) -> object: + """Delete the rule with the given topicName, subscriptionName and ruleName. + + Delete Subscription. + + :param topic_name: name of the topic. + :type topic_name: str + :param subscription_name: name of the subscription. + :type subscription_name: str + :param rule_name: name of the filter. + :type rule_name: str + :param api_version: Api Version. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', min_length=1), + 'ruleName': self._serialize.url("rule_name", rule_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_service_bus_management_client_operations_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_service_bus_management_client_operations_async.py index f57b483ede50..21cdba787565 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_service_bus_management_client_operations_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_service_bus_management_client_operations_async.py @@ -19,6 +19,146 @@ class ServiceBusManagementClientOperationsMixin: + async def list_subscriptions( + self, + topic_name: str, + skip: Optional[int] = 0, + top: Optional[int] = 100, + api_version: Optional[str] = "2017_04", + **kwargs + ) -> object: + """Get the details about the subscriptions of the given topic. + + Get subscriptions. + + :param topic_name: name of the topic. + :type topic_name: str + :param skip: + :type skip: int + :param top: + :type top: int + :param api_version: Api Version. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.list_subscriptions.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_subscriptions.metadata = {'url': '/{topicName}/subscriptions'} # type: ignore + + async def list_rules( + self, + topic_name: str, + subscription_name: str, + skip: Optional[int] = 0, + top: Optional[int] = 100, + api_version: Optional[str] = "2017_04", + **kwargs + ) -> object: + """Get the details about the rules of the given topic subscription. + + Get rules of a topic subscription. + + :param topic_name: name of the topic. + :type topic_name: str + :param subscription_name: name of the subscription. + :type subscription_name: str + :param skip: + :type skip: int + :param top: + :type top: int + :param api_version: Api Version. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.list_rules.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_rules.metadata = {'url': '/{topicName}/subscriptions/{subscriptionName}/rules'} # type: ignore + async def list_entities( self, entity_type: str, diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_subscription_operations_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_subscription_operations_async.py new file mode 100644 index 000000000000..1a7117c61ce9 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_subscription_operations_async.py @@ -0,0 +1,251 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionOperations: + """SubscriptionOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.servicebus.management._generated.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + topic_name: str, + subscription_name: str, + enrich: Optional[bool] = False, + api_version: Optional[str] = "2017_04", + **kwargs + ) -> object: + """Get the details about the subscription of a topic. + + Get Subscription. + + :param topic_name: name of the topic. + :type topic_name: str + :param subscription_name: name of the subscription. + :type subscription_name: str + :param enrich: A query parameter that sets enrich to true or false. + :type enrich: bool + :param api_version: Api Version. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if enrich is not None: + query_parameters['enrich'] = self._serialize.query("enrich", enrich, 'bool') + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + + async def put( + self, + topic_name: str, + subscription_name: str, + request_body: object, + api_version: Optional[str] = "2017_04", + if_match: Optional[str] = None, + **kwargs + ) -> object: + """Create or update a subscription. + + :param topic_name: name of the topic. + :type topic_name: str + :param subscription_name: name of the subscription. + :type subscription_name: str + :param request_body: Parameters required to make or edit a subscription. + :type request_body: object + :param api_version: Api Version. + :type api_version: str + :param if_match: Match condition for an entity to be updated. If specified and a matching + entity is not found, an error will be raised. To force an unconditional update, set to the + wildcard character (*). If not specified, an insert will be performed when no existing entity + is found to update and a replace will be performed if an existing entity is found. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/atom+xml") + + # Construct URL + url = self.put.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(request_body, 'object', is_xml=True) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + put.metadata = {'url': '/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + + async def delete( + self, + topic_name: str, + subscription_name: str, + api_version: Optional[str] = "2017_04", + **kwargs + ) -> object: + """Delete the subscription with the given topicName and subscriptionName. + + Delete Subscription. + + :param topic_name: name of the topic. + :type topic_name: str + :param subscription_name: name of the subscription. + :type subscription_name: str + :param api_version: Api Version. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/{topicName}/subscriptions/{subscriptionName}'} # type: ignore diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/__init__.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/__init__.py index 615df18aa74e..17337fa2c371 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/__init__.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/__init__.py @@ -8,66 +8,142 @@ try: from ._models_py3 import AuthorizationRule + from ._models_py3 import CorrelationFilter from ._models_py3 import CreateQueueBody from ._models_py3 import CreateQueueBodyContent + from ._models_py3 import CreateRuleBody + from ._models_py3 import CreateRuleBodyContent + from ._models_py3 import CreateSubscriptionBody + from ._models_py3 import CreateSubscriptionBodyContent from ._models_py3 import CreateTopicBody from ._models_py3 import CreateTopicBodyContent + from ._models_py3 import EmptyRuleAction + from ._models_py3 import FalseFilter + from ._models_py3 import KeyValue from ._models_py3 import MessageCountDetails + from ._models_py3 import NamespaceProperties + from ._models_py3 import NamespacePropertiesEntry + from ._models_py3 import NamespacePropertiesEntryContent from ._models_py3 import QueueDescription from ._models_py3 import QueueDescriptionEntry from ._models_py3 import QueueDescriptionEntryContent from ._models_py3 import QueueDescriptionFeed - from ._models_py3 import QueueDescriptionResponse - from ._models_py3 import QueueDescriptionResponseContent from ._models_py3 import ResponseAuthor from ._models_py3 import ResponseLink - from ._models_py3 import ResponseTitle + from ._models_py3 import RuleAction + from ._models_py3 import RuleDescription + from ._models_py3 import RuleDescriptionEntry + from ._models_py3 import RuleDescriptionEntryContent + from ._models_py3 import RuleDescriptionFeed + from ._models_py3 import RuleFilter from ._models_py3 import ServiceBusManagementError + from ._models_py3 import SqlFilter + from ._models_py3 import SqlRuleAction + from ._models_py3 import SubscriptionDescription + from ._models_py3 import SubscriptionDescriptionEntry + from ._models_py3 import SubscriptionDescriptionEntryContent + from ._models_py3 import SubscriptionDescriptionFeed from ._models_py3 import TopicDescription + from ._models_py3 import TopicDescriptionEntry + from ._models_py3 import TopicDescriptionEntryContent + from ._models_py3 import TopicDescriptionFeed + from ._models_py3 import TrueFilter except (SyntaxError, ImportError): from ._models import AuthorizationRule # type: ignore + from ._models import CorrelationFilter # type: ignore from ._models import CreateQueueBody # type: ignore from ._models import CreateQueueBodyContent # type: ignore + from ._models import CreateRuleBody # type: ignore + from ._models import CreateRuleBodyContent # type: ignore + from ._models import CreateSubscriptionBody # type: ignore + from ._models import CreateSubscriptionBodyContent # type: ignore from ._models import CreateTopicBody # type: ignore from ._models import CreateTopicBodyContent # type: ignore + from ._models import EmptyRuleAction # type: ignore + from ._models import FalseFilter # type: ignore + from ._models import KeyValue # type: ignore from ._models import MessageCountDetails # type: ignore + from ._models import NamespaceProperties # type: ignore + from ._models import NamespacePropertiesEntry # type: ignore + from ._models import NamespacePropertiesEntryContent # type: ignore from ._models import QueueDescription # type: ignore from ._models import QueueDescriptionEntry # type: ignore from ._models import QueueDescriptionEntryContent # type: ignore from ._models import QueueDescriptionFeed # type: ignore - from ._models import QueueDescriptionResponse # type: ignore - from ._models import QueueDescriptionResponseContent # type: ignore from ._models import ResponseAuthor # type: ignore from ._models import ResponseLink # type: ignore - from ._models import ResponseTitle # type: ignore + from ._models import RuleAction # type: ignore + from ._models import RuleDescription # type: ignore + from ._models import RuleDescriptionEntry # type: ignore + from ._models import RuleDescriptionEntryContent # type: ignore + from ._models import RuleDescriptionFeed # type: ignore + from ._models import RuleFilter # type: ignore from ._models import ServiceBusManagementError # type: ignore + from ._models import SqlFilter # type: ignore + from ._models import SqlRuleAction # type: ignore + from ._models import SubscriptionDescription # type: ignore + from ._models import SubscriptionDescriptionEntry # type: ignore + from ._models import SubscriptionDescriptionEntryContent # type: ignore + from ._models import SubscriptionDescriptionFeed # type: ignore from ._models import TopicDescription # type: ignore + from ._models import TopicDescriptionEntry # type: ignore + from ._models import TopicDescriptionEntryContent # type: ignore + from ._models import TopicDescriptionFeed # type: ignore + from ._models import TrueFilter # type: ignore from ._service_bus_management_client_enums import ( AccessRights, EntityAvailabilityStatus, EntityStatus, + MessagingSku, + NamespaceType, ) __all__ = [ 'AuthorizationRule', + 'CorrelationFilter', 'CreateQueueBody', 'CreateQueueBodyContent', + 'CreateRuleBody', + 'CreateRuleBodyContent', + 'CreateSubscriptionBody', + 'CreateSubscriptionBodyContent', 'CreateTopicBody', 'CreateTopicBodyContent', + 'EmptyRuleAction', + 'FalseFilter', + 'KeyValue', 'MessageCountDetails', + 'NamespaceProperties', + 'NamespacePropertiesEntry', + 'NamespacePropertiesEntryContent', 'QueueDescription', 'QueueDescriptionEntry', 'QueueDescriptionEntryContent', 'QueueDescriptionFeed', - 'QueueDescriptionResponse', - 'QueueDescriptionResponseContent', 'ResponseAuthor', 'ResponseLink', - 'ResponseTitle', + 'RuleAction', + 'RuleDescription', + 'RuleDescriptionEntry', + 'RuleDescriptionEntryContent', + 'RuleDescriptionFeed', + 'RuleFilter', 'ServiceBusManagementError', + 'SqlFilter', + 'SqlRuleAction', + 'SubscriptionDescription', + 'SubscriptionDescriptionEntry', + 'SubscriptionDescriptionEntryContent', + 'SubscriptionDescriptionFeed', 'TopicDescription', + 'TopicDescriptionEntry', + 'TopicDescriptionEntryContent', + 'TopicDescriptionFeed', + 'TrueFilter', 'AccessRights', 'EntityAvailabilityStatus', 'EntityStatus', + 'MessagingSku', + 'NamespaceType', ] diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_models.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_models.py index 7de15a1b07b1..495895a71eea 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_models.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_models.py @@ -64,6 +64,90 @@ def __init__( self.secondary_key = kwargs.get('secondary_key', None) +class RuleFilter(msrest.serialization.Model): + """RuleFilter. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: CorrelationFilter, FalseFilter, SqlFilter, TrueFilter. + + :param type: Constant filled by server. + :type type: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + } + + _subtype_map = { + 'type': {'CorrelationFilter': 'CorrelationFilter', 'FalseFilter': 'FalseFilter', 'SqlFilter': 'SqlFilter', 'TrueFilter': 'TrueFilter'} + } + _xml_map = { + 'name': 'Filter', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' + } + + def __init__( + self, + **kwargs + ): + super(RuleFilter, self).__init__(**kwargs) + self.type = None + + +class CorrelationFilter(RuleFilter): + """CorrelationFilter. + + :param type: Constant filled by server. + :type type: str + :param correlation_id: + :type correlation_id: str + :param message_id: + :type message_id: str + :param to: + :type to: str + :param reply_to: + :type reply_to: str + :param label: + :type label: str + :param session_id: + :type session_id: str + :param reply_to_session_id: + :type reply_to_session_id: str + :param content_type: + :type content_type: str + :param properties: + :type properties: list[~azure.servicebus.management._generated.models.KeyValue] + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + 'correlation_id': {'key': 'CorrelationId', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'message_id': {'key': 'MessageId', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'to': {'key': 'To', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'reply_to': {'key': 'ReplyTo', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'label': {'key': 'Label', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'session_id': {'key': 'SessionId', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'reply_to_session_id': {'key': 'ReplyToSessionId', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'content_type': {'key': 'ContentType', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'properties': {'key': 'Properties', 'type': '[KeyValue]', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'KeyValueOfstringanyType', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + + def __init__( + self, + **kwargs + ): + super(CorrelationFilter, self).__init__(**kwargs) + self.type = 'CorrelationFilter' + self.correlation_id = kwargs.get('correlation_id', None) + self.message_id = kwargs.get('message_id', None) + self.to = kwargs.get('to', None) + self.reply_to = kwargs.get('reply_to', None) + self.label = kwargs.get('label', None) + self.session_id = kwargs.get('session_id', None) + self.reply_to_session_id = kwargs.get('reply_to_session_id', None) + self.content_type = kwargs.get('content_type', None) + self.properties = kwargs.get('properties', None) + + class CreateQueueBody(msrest.serialization.Model): """The request body for creating a queue. @@ -112,15 +196,15 @@ def __init__( self.queue_description = kwargs.get('queue_description', None) -class CreateTopicBody(msrest.serialization.Model): +class CreateRuleBody(msrest.serialization.Model): """The request body for creating a topic. - :param content: TopicDescription for the new topic. - :type content: ~azure.servicebus.management._generated.models.CreateTopicBodyContent + :param content: RuleDescription for the new Rule. + :type content: ~azure.servicebus.management._generated.models.CreateRuleBodyContent """ _attribute_map = { - 'content': {'key': 'content', 'type': 'CreateTopicBodyContent'}, + 'content': {'key': 'content', 'type': 'CreateRuleBodyContent'}, } _xml_map = { 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' @@ -130,22 +214,22 @@ def __init__( self, **kwargs ): - super(CreateTopicBody, self).__init__(**kwargs) + super(CreateRuleBody, self).__init__(**kwargs) self.content = kwargs.get('content', None) -class CreateTopicBodyContent(msrest.serialization.Model): - """TopicDescription for the new topic. +class CreateRuleBodyContent(msrest.serialization.Model): + """RuleDescription for the new Rule. :param type: MIME type of content. :type type: str - :param topic_description: Topic information to create. - :type topic_description: ~azure.servicebus.management._generated.models.TopicDescription + :param rule_description: Rule information to create. + :type rule_description: ~azure.servicebus.management._generated.models.RuleDescription """ _attribute_map = { 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, - 'topic_description': {'key': 'TopicDescription', 'type': 'TopicDescription'}, + 'rule_description': {'key': 'RuleDescription', 'type': 'RuleDescription'}, } _xml_map = { 'ns': 'http://www.w3.org/2005/Atom' @@ -155,210 +239,69 @@ def __init__( self, **kwargs ): - super(CreateTopicBodyContent, self).__init__(**kwargs) + super(CreateRuleBodyContent, self).__init__(**kwargs) self.type = kwargs.get('type', "application/xml") - self.topic_description = kwargs.get('topic_description', None) + self.rule_description = kwargs.get('rule_description', None) -class MessageCountDetails(msrest.serialization.Model): - """Details about the message counts in queue. +class CreateSubscriptionBody(msrest.serialization.Model): + """The request body for creating a topic. - :param active_message_count: Number of active messages in the queue, topic, or subscription. - :type active_message_count: int - :param dead_letter_message_count: Number of messages that are dead lettered. - :type dead_letter_message_count: int - :param scheduled_message_count: Number of scheduled messages. - :type scheduled_message_count: int - :param transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :type transfer_dead_letter_message_count: int - :param transfer_message_count: Number of messages transferred to another queue, topic, or - subscription. - :type transfer_message_count: int + :param content: TopicDescription for the new topic. + :type content: ~azure.servicebus.management._generated.models.CreateSubscriptionBodyContent """ _attribute_map = { - 'active_message_count': {'key': 'ActiveMessageCount', 'type': 'int', 'xml': {'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, - 'dead_letter_message_count': {'key': 'DeadLetterMessageCount', 'type': 'int', 'xml': {'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, - 'scheduled_message_count': {'key': 'ScheduledMessageCount', 'type': 'int', 'xml': {'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, - 'transfer_dead_letter_message_count': {'key': 'TransferDeadLetterMessageCount', 'type': 'int', 'xml': {'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, - 'transfer_message_count': {'key': 'TransferMessageCount', 'type': 'int', 'xml': {'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, + 'content': {'key': 'content', 'type': 'CreateSubscriptionBodyContent'}, } _xml_map = { - 'name': 'CountDetails', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' + 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' } def __init__( self, **kwargs ): - super(MessageCountDetails, self).__init__(**kwargs) - self.active_message_count = kwargs.get('active_message_count', None) - self.dead_letter_message_count = kwargs.get('dead_letter_message_count', None) - self.scheduled_message_count = kwargs.get('scheduled_message_count', None) - self.transfer_dead_letter_message_count = kwargs.get('transfer_dead_letter_message_count', None) - self.transfer_message_count = kwargs.get('transfer_message_count', None) + super(CreateSubscriptionBody, self).__init__(**kwargs) + self.content = kwargs.get('content', None) -class QueueDescription(msrest.serialization.Model): - """Description of a Service Bus queue resource. +class CreateSubscriptionBodyContent(msrest.serialization.Model): + """TopicDescription for the new topic. - :param authorization_rules: Authorization rules for resource. - :type authorization_rules: - list[~azure.servicebus.management._generated.models.AuthorizationRule] - :param auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the queue is - automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: ~datetime.timedelta - :param created_at: The exact time the queue was created. - :type created_at: ~datetime.datetime - :param dead_lettering_on_message_expiration: A value that indicates whether this queue has dead - letter support when a message expires. - :type dead_lettering_on_message_expiration: bool - :param default_message_time_to_live: ISO 8601 default message timespan to live value. This is - the duration after which the message expires, starting from when the message is sent to Service - Bus. This is the default value used when TimeToLive is not set on a message itself. - :type default_message_time_to_live: ~datetime.timedelta - :param duplicate_detection_history_time_window: ISO 8601 timeSpan structure that defines the - duration of the duplicate detection history. The default value is 10 minutes. - :type duplicate_detection_history_time_window: ~datetime.timedelta - :param entity_availability_status: Availibility status of the entity. Possible values include: - "Available", "Limited", "Renaming", "Restoring", "Unknown". - :type entity_availability_status: str or - ~azure.servicebus.management._generated.models.EntityAvailabilityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :param enable_express: A value that indicates whether Express Entities are enabled. An express - queue holds a message in memory temporarily before writing it to persistent storage. - :type enable_express: bool - :param enable_partitioning: A value that indicates whether the queue is to be partitioned - across multiple message brokers. - :type enable_partitioning: bool - :param is_anonymous_accessible: A value indicating if the resource can be accessed without - authorization. - :type is_anonymous_accessible: bool - :param lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time - that the message is locked for other receivers. The maximum value for LockDuration is 5 - minutes; the default value is 1 minute. - :type lock_duration: ~datetime.timedelta - :param max_delivery_count: The maximum delivery count. A message is automatically deadlettered - after this number of deliveries. Default value is 10. - :type max_delivery_count: int - :param max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size of - memory allocated for the queue. - :type max_size_in_megabytes: int - :param requires_duplicate_detection: A value indicating if this queue requires duplicate - detection. - :type requires_duplicate_detection: bool - :param requires_session: A value that indicates whether the queue supports the concept of - sessions. - :type requires_session: bool - :param status: Status of a Service Bus resource. Possible values include: "Active", "Creating", - "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". - :type status: str or ~azure.servicebus.management._generated.models.EntityStatus - :param support_ordering: A value that indicates whether the queue supports ordering. - :type support_ordering: bool - :param accessed_at: Last time a message was sent, or the last time there was a receive request - to this queue. - :type accessed_at: ~datetime.datetime - :param updated_at: The exact time a message was updated in the queue. - :type updated_at: ~datetime.datetime - :param size_in_bytes: The size of the queue, in bytes. - :type size_in_bytes: int - :param message_count: The number of messages in the queue. - :type message_count: int - :param message_count_details: Details about the message counts in queue. - :type message_count_details: ~azure.servicebus.management._generated.models.MessageCountDetails + :param type: MIME type of content. + :type type: str + :param subscription_description: Topic information to create. + :type subscription_description: + ~azure.servicebus.management._generated.models.SubscriptionDescription """ _attribute_map = { - 'authorization_rules': {'key': 'AuthorizationRules', 'type': '[AuthorizationRule]', 'xml': {'name': 'AuthorizationRules', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'AuthorizationRule', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'auto_delete_on_idle': {'key': 'AutoDeleteOnIdle', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'created_at': {'key': 'CreatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'dead_lettering_on_message_expiration': {'key': 'DeadLetteringOnMessageExpiration', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'default_message_time_to_live': {'key': 'DefaultMessageTimeToLive', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'duplicate_detection_history_time_window': {'key': 'DuplicateDetectionHistoryTimeWindow', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'entity_availability_status': {'key': 'EntityAvailabilityStatus', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_batched_operations': {'key': 'EnableBatchedOperations', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_express': {'key': 'EnableExpress', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_partitioning': {'key': 'EnablePartitioning', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'is_anonymous_accessible': {'key': 'IsAnonymousAccessible', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'lock_duration': {'key': 'LockDuration', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_delivery_count': {'key': 'MaxDeliveryCount', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_size_in_megabytes': {'key': 'MaxSizeInMegabytes', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_duplicate_detection': {'key': 'RequiresDuplicateDetection', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_session': {'key': 'RequiresSession', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'status': {'key': 'Status', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'support_ordering': {'key': 'SupportOrdering', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'accessed_at': {'key': 'AccessedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'updated_at': {'key': 'UpdatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'size_in_bytes': {'key': 'SizeInBytes', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'message_count': {'key': 'MessageCount', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'message_count_details': {'key': 'MessageCountDetails', 'type': 'MessageCountDetails'}, + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, + 'subscription_description': {'key': 'SubscriptionDescription', 'type': 'SubscriptionDescription'}, } _xml_map = { - 'name': 'QueueDescription', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' + 'ns': 'http://www.w3.org/2005/Atom' } def __init__( self, **kwargs ): - super(QueueDescription, self).__init__(**kwargs) - self.authorization_rules = kwargs.get('authorization_rules', None) - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.created_at = kwargs.get('created_at', None) - self.dead_lettering_on_message_expiration = kwargs.get('dead_lettering_on_message_expiration', None) - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.duplicate_detection_history_time_window = kwargs.get('duplicate_detection_history_time_window', None) - self.entity_availability_status = kwargs.get('entity_availability_status', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.enable_express = kwargs.get('enable_express', None) - self.enable_partitioning = kwargs.get('enable_partitioning', None) - self.is_anonymous_accessible = kwargs.get('is_anonymous_accessible', None) - self.lock_duration = kwargs.get('lock_duration', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.max_size_in_megabytes = kwargs.get('max_size_in_megabytes', None) - self.requires_duplicate_detection = kwargs.get('requires_duplicate_detection', None) - self.requires_session = kwargs.get('requires_session', None) - self.status = kwargs.get('status', None) - self.support_ordering = kwargs.get('support_ordering', None) - self.accessed_at = kwargs.get('accessed_at', None) - self.updated_at = kwargs.get('updated_at', None) - self.size_in_bytes = kwargs.get('size_in_bytes', None) - self.message_count = kwargs.get('message_count', None) - self.message_count_details = kwargs.get('message_count_details', None) + super(CreateSubscriptionBodyContent, self).__init__(**kwargs) + self.type = kwargs.get('type', "application/xml") + self.subscription_description = kwargs.get('subscription_description', None) -class QueueDescriptionEntry(msrest.serialization.Model): - """Represents an entry in the feed when querying queues. +class CreateTopicBody(msrest.serialization.Model): + """The request body for creating a topic. - :param base: Base URL for the query. - :type base: str - :param id: The URL of the GET request. - :type id: str - :param title: The name of the queue. - :type title: ~azure.servicebus.management._generated.models.ResponseTitle - :param published: The timestamp for when this queue was published. - :type published: ~datetime.datetime - :param updated: The timestamp for when this queue was last updated. - :type updated: ~datetime.datetime - :param author: The author that created this resource. - :type author: ~azure.servicebus.management._generated.models.ResponseAuthor - :param link: The URL for the HTTP request. - :type link: ~azure.servicebus.management._generated.models.ResponseLink - :param content: The QueueDescription. - :type content: ~azure.servicebus.management._generated.models.QueueDescriptionEntryContent + :param content: TopicDescription for the new topic. + :type content: ~azure.servicebus.management._generated.models.CreateTopicBodyContent """ _attribute_map = { - 'base': {'key': 'base', 'type': 'str', 'xml': {'name': 'base', 'attr': True, 'prefix': 'xml'}}, - 'id': {'key': 'id', 'type': 'str'}, - 'title': {'key': 'title', 'type': 'ResponseTitle'}, - 'published': {'key': 'published', 'type': 'iso-8601'}, - 'updated': {'key': 'updated', 'type': 'iso-8601'}, - 'author': {'key': 'author', 'type': 'ResponseAuthor'}, - 'link': {'key': 'link', 'type': 'ResponseLink'}, - 'content': {'key': 'content', 'type': 'QueueDescriptionEntryContent'}, + 'content': {'key': 'content', 'type': 'CreateTopicBodyContent'}, } _xml_map = { 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' @@ -368,309 +311,1249 @@ def __init__( self, **kwargs ): - super(QueueDescriptionEntry, self).__init__(**kwargs) - self.base = kwargs.get('base', None) - self.id = kwargs.get('id', None) - self.title = kwargs.get('title', None) - self.published = kwargs.get('published', None) - self.updated = kwargs.get('updated', None) - self.author = kwargs.get('author', None) - self.link = kwargs.get('link', None) + super(CreateTopicBody, self).__init__(**kwargs) self.content = kwargs.get('content', None) -class QueueDescriptionEntryContent(msrest.serialization.Model): - """The QueueDescription. +class CreateTopicBodyContent(msrest.serialization.Model): + """TopicDescription for the new topic. - :param type: Type of content in queue response. + :param type: MIME type of content. :type type: str - :param queue_description: Description of a Service Bus queue resource. - :type queue_description: ~azure.servicebus.management._generated.models.QueueDescription + :param topic_description: Topic information to create. + :type topic_description: ~azure.servicebus.management._generated.models.TopicDescription """ _attribute_map = { 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, - 'queue_description': {'key': 'QueueDescription', 'type': 'QueueDescription'}, + 'topic_description': {'key': 'TopicDescription', 'type': 'TopicDescription'}, + } + _xml_map = { + 'ns': 'http://www.w3.org/2005/Atom' } def __init__( self, **kwargs ): - super(QueueDescriptionEntryContent, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.queue_description = kwargs.get('queue_description', None) + super(CreateTopicBodyContent, self).__init__(**kwargs) + self.type = kwargs.get('type', "application/xml") + self.topic_description = kwargs.get('topic_description', None) -class QueueDescriptionFeed(msrest.serialization.Model): - """Response from listing Service Bus queues. +class RuleAction(msrest.serialization.Model): + """RuleAction. - :param id: URL of the list queues query. - :type id: str - :param title: The entity type for the feed. - :type title: str - :param updated: Datetime of the query. - :type updated: ~datetime.datetime - :param link: Links to paginated response. - :type link: list[~azure.servicebus.management._generated.models.ResponseLink] - :param entry: Queue entries. - :type entry: list[~azure.servicebus.management._generated.models.QueueDescriptionEntry] + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: EmptyRuleAction, SqlRuleAction. + + :param type: Constant filled by server. + :type type: str """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'title': {'key': 'title', 'type': 'str'}, - 'updated': {'key': 'updated', 'type': 'iso-8601'}, - 'link': {'key': 'link', 'type': '[ResponseLink]'}, - 'entry': {'key': 'entry', 'type': '[QueueDescriptionEntry]'}, + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + } + + _subtype_map = { + 'type': {'EmptyRuleAction': 'EmptyRuleAction', 'SqlRuleAction': 'SqlRuleAction'} } _xml_map = { - 'name': 'feed', 'ns': 'http://www.w3.org/2005/Atom' + 'name': 'Action', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' } def __init__( self, **kwargs ): - super(QueueDescriptionFeed, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.title = kwargs.get('title', None) - self.updated = kwargs.get('updated', None) - self.link = kwargs.get('link', None) - self.entry = kwargs.get('entry', None) + super(RuleAction, self).__init__(**kwargs) + self.type = None -class QueueDescriptionResponse(msrest.serialization.Model): - """The response from a Queue_Get operation. +class EmptyRuleAction(RuleAction): + """EmptyRuleAction. - :param id: The URL of the GET request. - :type id: str - :param title: The name of the queue. - :type title: str - :param published: The timestamp for when this queue was published. - :type published: str - :param updated: The timestamp for when this queue was last updated. - :type updated: str - :param author: The author that created this resource. - :type author: ~azure.servicebus.management._generated.models.ResponseAuthor - :param link: The URL for the HTTP request. - :type link: ~azure.servicebus.management._generated.models.ResponseLink - :param content: Contents of a Queue_Get response. - :type content: ~azure.servicebus.management._generated.models.QueueDescriptionResponseContent + :param type: Constant filled by server. + :type type: str """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'title': {'key': 'title', 'type': 'str'}, - 'published': {'key': 'published', 'type': 'str'}, - 'updated': {'key': 'updated', 'type': 'str'}, - 'author': {'key': 'author', 'type': 'ResponseAuthor'}, - 'link': {'key': 'link', 'type': 'ResponseLink'}, - 'content': {'key': 'content', 'type': 'QueueDescriptionResponseContent'}, - } - _xml_map = { - 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, } def __init__( self, **kwargs ): - super(QueueDescriptionResponse, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.title = kwargs.get('title', None) - self.published = kwargs.get('published', None) - self.updated = kwargs.get('updated', None) - self.author = kwargs.get('author', None) - self.link = kwargs.get('link', None) - self.content = kwargs.get('content', None) + super(EmptyRuleAction, self).__init__(**kwargs) + self.type = 'EmptyRuleAction' -class QueueDescriptionResponseContent(msrest.serialization.Model): - """Contents of a Queue_Get response. +class FalseFilter(RuleFilter): + """FalseFilter. - :param type: Type of content in queue response. + :param type: Constant filled by server. :type type: str - :param queue_description: Description of a Service Bus queue resource. - :type queue_description: ~azure.servicebus.management._generated.models.QueueDescription + :param sql_expression: + :type sql_expression: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, - 'queue_description': {'key': 'QueueDescription', 'type': 'QueueDescription'}, + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + 'sql_expression': {'key': 'SqlExpression', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, } def __init__( self, **kwargs ): - super(QueueDescriptionResponseContent, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.queue_description = kwargs.get('queue_description', None) + super(FalseFilter, self).__init__(**kwargs) + self.type = 'FalseFilter' + self.sql_expression = kwargs.get('sql_expression', "1 != 1") -class ResponseAuthor(msrest.serialization.Model): - """The author that created this resource. +class KeyValue(msrest.serialization.Model): + """KeyValue. - :param name: The Service Bus namespace. - :type name: str + :param key: + :type key: str + :param value: + :type value: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + 'key': {'key': 'Key', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'value': {'key': 'Value', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + _xml_map = { + 'name': 'KeyValueOfstringanyType', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' } def __init__( self, **kwargs ): - super(ResponseAuthor, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + super(KeyValue, self).__init__(**kwargs) + self.key = kwargs.get('key', None) + self.value = kwargs.get('value', None) -class ResponseLink(msrest.serialization.Model): - """The URL for the HTTP request. +class MessageCountDetails(msrest.serialization.Model): + """Details about the message counts in queue. - :param href: The URL of the GET request. - :type href: str - :param rel: What the link href is relative to. - :type rel: str + :param active_message_count: Number of active messages in the queue, topic, or subscription. + :type active_message_count: int + :param dead_letter_message_count: Number of messages that are dead lettered. + :type dead_letter_message_count: int + :param scheduled_message_count: Number of scheduled messages. + :type scheduled_message_count: int + :param transfer_dead_letter_message_count: Number of messages transferred into dead letters. + :type transfer_dead_letter_message_count: int + :param transfer_message_count: Number of messages transferred to another queue, topic, or + subscription. + :type transfer_message_count: int """ _attribute_map = { - 'href': {'key': 'href', 'type': 'str', 'xml': {'attr': True}}, - 'rel': {'key': 'rel', 'type': 'str', 'xml': {'attr': True}}, + 'active_message_count': {'key': 'ActiveMessageCount', 'type': 'int', 'xml': {'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, + 'dead_letter_message_count': {'key': 'DeadLetterMessageCount', 'type': 'int', 'xml': {'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, + 'scheduled_message_count': {'key': 'ScheduledMessageCount', 'type': 'int', 'xml': {'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, + 'transfer_dead_letter_message_count': {'key': 'TransferDeadLetterMessageCount', 'type': 'int', 'xml': {'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, + 'transfer_message_count': {'key': 'TransferMessageCount', 'type': 'int', 'xml': {'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, } _xml_map = { - 'name': 'link', 'ns': 'http://www.w3.org/2005/Atom' + 'name': 'CountDetails', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' } def __init__( self, **kwargs ): - super(ResponseLink, self).__init__(**kwargs) - self.href = kwargs.get('href', None) - self.rel = kwargs.get('rel', None) + super(MessageCountDetails, self).__init__(**kwargs) + self.active_message_count = kwargs.get('active_message_count', None) + self.dead_letter_message_count = kwargs.get('dead_letter_message_count', None) + self.scheduled_message_count = kwargs.get('scheduled_message_count', None) + self.transfer_dead_letter_message_count = kwargs.get('transfer_dead_letter_message_count', None) + self.transfer_message_count = kwargs.get('transfer_message_count', None) -class ResponseTitle(msrest.serialization.Model): - """The title of the response. +class NamespaceProperties(msrest.serialization.Model): + """The metadata related to a Service Bus namespace. - :param type: Type of value. - :type type: str - :param title: Contents of the title. - :type title: str + :param alias: Alias for the geo-disaster recovery Service Bus namespace. + :type alias: str + :param created_time: The exact time the namespace was created. + :type created_time: ~datetime.datetime + :param messaging_sku: The SKU for the messaging entity. Possible values include: "Basic", + "Standard", "Premium". + :type messaging_sku: str or ~azure.servicebus.management._generated.models.MessagingSku + :param messaging_units: The number of messaging units allocated to the namespace. + :type messaging_units: int + :param modified_time: The exact time the namespace was last modified. + :type modified_time: ~datetime.datetime + :param name: Name of the namespace. + :type name: str + :param namespace_type: The type of entities the namespace can contain. Possible values include: + "Messaging", "NotificationHub", "Mixed", "EventHub", "Relay". + :type namespace_type: str or ~azure.servicebus.management._generated.models.NamespaceType """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, - 'title': {'key': 'title', 'type': 'str'}, + 'alias': {'key': 'Alias', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'created_time': {'key': 'CreatedTime', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'messaging_sku': {'key': 'MessagingSku', 'type': 'str', 'xml': {'name': 'MessagingSKU', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'messaging_units': {'key': 'MessagingUnits', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'modified_time': {'key': 'ModifiedTime', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'name': {'key': 'Name', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'namespace_type': {'key': 'NamespaceType', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + _xml_map = { + 'name': 'NamespaceInfo', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' } def __init__( self, **kwargs ): - super(ResponseTitle, self).__init__(**kwargs) - self.type = kwargs.get('type', None) + super(NamespaceProperties, self).__init__(**kwargs) + self.alias = kwargs.get('alias', None) + self.created_time = kwargs.get('created_time', None) + self.messaging_sku = kwargs.get('messaging_sku', None) + self.messaging_units = kwargs.get('messaging_units', None) + self.modified_time = kwargs.get('modified_time', None) + self.name = kwargs.get('name', None) + self.namespace_type = kwargs.get('namespace_type', None) + + +class NamespacePropertiesEntry(msrest.serialization.Model): + """Represents an entry in the feed when querying namespace info. + + :param id: The URL of the GET request. + :type id: str + :param title: The name of the namespace. + :type title: object + :param updated: The timestamp for when this namespace was last updated. + :type updated: ~datetime.datetime + :param author: The author that created this resource. + :type author: ~azure.servicebus.management._generated.models.ResponseAuthor + :param link: The URL for the HTTP request. + :type link: ~azure.servicebus.management._generated.models.ResponseLink + :param content: Information about the namespace. + :type content: ~azure.servicebus.management._generated.models.NamespacePropertiesEntryContent + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'author': {'key': 'author', 'type': 'ResponseAuthor'}, + 'link': {'key': 'link', 'type': 'ResponseLink'}, + 'content': {'key': 'content', 'type': 'NamespacePropertiesEntryContent'}, + } + _xml_map = { + 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + **kwargs + ): + super(NamespacePropertiesEntry, self).__init__(**kwargs) + self.id = kwargs.get('id', None) self.title = kwargs.get('title', None) + self.updated = kwargs.get('updated', None) + self.author = kwargs.get('author', None) + self.link = kwargs.get('link', None) + self.content = kwargs.get('content', None) -class ServiceBusManagementError(msrest.serialization.Model): - """The error response from Service Bus. +class NamespacePropertiesEntryContent(msrest.serialization.Model): + """Information about the namespace. - :param code: The service error code. - :type code: int - :param detail: The service error message. - :type detail: str + :param type: Type of content in namespace info response. + :type type: str + :param namespace_properties: The metadata related to a Service Bus namespace. + :type namespace_properties: ~azure.servicebus.management._generated.models.NamespaceProperties """ _attribute_map = { - 'code': {'key': 'Code', 'type': 'int'}, - 'detail': {'key': 'Detail', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, + 'namespace_properties': {'key': 'NamespaceProperties', 'type': 'NamespaceProperties'}, + } + _xml_map = { + 'ns': 'http://www.w3.org/2005/Atom' } def __init__( self, **kwargs ): - super(ServiceBusManagementError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.detail = kwargs.get('detail', None) + super(NamespacePropertiesEntryContent, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.namespace_properties = kwargs.get('namespace_properties', None) -class TopicDescription(msrest.serialization.Model): - """Description of a Service Bus topic resource. +class QueueDescription(msrest.serialization.Model): + """Description of a Service Bus queue resource. - :param topic_name: Name of the topic. - :type topic_name: str - :param authorization_rules: Authorization rules for resource. - :type authorization_rules: - list[~azure.servicebus.management._generated.models.AuthorizationRule] - :param auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the topic is - automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: ~datetime.timedelta + :param lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time + that the message is locked for other receivers. The maximum value for LockDuration is 5 + minutes; the default value is 1 minute. + :type lock_duration: ~datetime.timedelta + :param max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size of + memory allocated for the queue. + :type max_size_in_megabytes: int + :param requires_duplicate_detection: A value indicating if this queue requires duplicate + detection. + :type requires_duplicate_detection: bool + :param requires_session: A value that indicates whether the queue supports the concept of + sessions. + :type requires_session: bool :param default_message_time_to_live: ISO 8601 default message timespan to live value. This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself. :type default_message_time_to_live: ~datetime.timedelta + :param dead_lettering_on_message_expiration: A value that indicates whether this queue has dead + letter support when a message expires. + :type dead_lettering_on_message_expiration: bool :param duplicate_detection_history_time_window: ISO 8601 timeSpan structure that defines the duration of the duplicate detection history. The default value is 10 minutes. :type duplicate_detection_history_time_window: ~datetime.timedelta + :param max_delivery_count: The maximum delivery count. A message is automatically deadlettered + after this number of deliveries. Default value is 10. + :type max_delivery_count: int :param enable_batched_operations: Value that indicates whether server-side batched operations are enabled. :type enable_batched_operations: bool - :param enable_partitioning: A value that indicates whether the topic is to be partitioned - across multiple message brokers. - :type enable_partitioning: bool - :param max_size_in_megabytes: The maximum size of the topic in megabytes, which is the size of - memory allocated for the topic. - :type max_size_in_megabytes: long - :param requires_duplicate_detection: A value indicating if this topic requires duplicate - detection. - :type requires_duplicate_detection: bool + :param size_in_bytes: The size of the queue, in bytes. + :type size_in_bytes: int + :param message_count: The number of messages in the queue. + :type message_count: int + :param is_anonymous_accessible: A value indicating if the resource can be accessed without + authorization. + :type is_anonymous_accessible: bool + :param authorization_rules: Authorization rules for resource. + :type authorization_rules: + list[~azure.servicebus.management._generated.models.AuthorizationRule] :param status: Status of a Service Bus resource. Possible values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". :type status: str or ~azure.servicebus.management._generated.models.EntityStatus - :param support_ordering: A value that indicates whether the topic supports ordering. + :param created_at: The exact time the queue was created. + :type created_at: ~datetime.datetime + :param updated_at: The exact time a message was updated in the queue. + :type updated_at: ~datetime.datetime + :param accessed_at: Last time a message was sent, or the last time there was a receive request + to this queue. + :type accessed_at: ~datetime.datetime + :param support_ordering: A value that indicates whether the queue supports ordering. :type support_ordering: bool - :param user_metadata: Metadata associated with the topic. - :type user_metadata: str + :param message_count_details: Details about the message counts in queue. + :type message_count_details: ~azure.servicebus.management._generated.models.MessageCountDetails + :param auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the queue is + automatically deleted. The minimum duration is 5 minutes. + :type auto_delete_on_idle: ~datetime.timedelta + :param enable_partitioning: A value that indicates whether the queue is to be partitioned + across multiple message brokers. + :type enable_partitioning: bool + :param entity_availability_status: Availability status of the entity. Possible values include: + "Available", "Limited", "Renaming", "Restoring", "Unknown". + :type entity_availability_status: str or + ~azure.servicebus.management._generated.models.EntityAvailabilityStatus + :param enable_express: A value that indicates whether Express Entities are enabled. An express + queue holds a message in memory temporarily before writing it to persistent storage. + :type enable_express: bool """ _attribute_map = { - 'topic_name': {'key': 'TopicName', 'type': 'str'}, - 'authorization_rules': {'key': 'AuthorizationRules', 'type': '[AuthorizationRule]', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'AuthorizationRule', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'auto_delete_on_idle': {'key': 'AutoDeleteOnIdle', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'lock_duration': {'key': 'LockDuration', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'max_size_in_megabytes': {'key': 'MaxSizeInMegabytes', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'requires_duplicate_detection': {'key': 'RequiresDuplicateDetection', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'requires_session': {'key': 'RequiresSession', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, 'default_message_time_to_live': {'key': 'DefaultMessageTimeToLive', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'dead_lettering_on_message_expiration': {'key': 'DeadLetteringOnMessageExpiration', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, 'duplicate_detection_history_time_window': {'key': 'DuplicateDetectionHistoryTimeWindow', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'max_delivery_count': {'key': 'MaxDeliveryCount', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, 'enable_batched_operations': {'key': 'EnableBatchedOperations', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_partitioning': {'key': 'EnablePartitioning', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_size_in_megabytes': {'key': 'MaxSizeInMegabytes', 'type': 'long'}, - 'requires_duplicate_detection': {'key': 'RequiresDuplicateDetection', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'size_in_bytes': {'key': 'SizeInBytes', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'message_count': {'key': 'MessageCount', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'is_anonymous_accessible': {'key': 'IsAnonymousAccessible', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'authorization_rules': {'key': 'AuthorizationRules', 'type': '[AuthorizationRule]', 'xml': {'name': 'AuthorizationRules', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'AuthorizationRule', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, 'status': {'key': 'Status', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'created_at': {'key': 'CreatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'updated_at': {'key': 'UpdatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'accessed_at': {'key': 'AccessedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, 'support_ordering': {'key': 'SupportOrdering', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'user_metadata': {'key': 'UserMetadata', 'type': 'str'}, + 'message_count_details': {'key': 'MessageCountDetails', 'type': 'MessageCountDetails'}, + 'auto_delete_on_idle': {'key': 'AutoDeleteOnIdle', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'enable_partitioning': {'key': 'EnablePartitioning', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'entity_availability_status': {'key': 'EntityAvailabilityStatus', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'enable_express': {'key': 'EnableExpress', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, } _xml_map = { - 'name': 'TopicDescription', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' + 'name': 'QueueDescription', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' } def __init__( self, **kwargs ): - super(TopicDescription, self).__init__(**kwargs) - self.topic_name = kwargs.get('topic_name', None) - self.authorization_rules = kwargs.get('authorization_rules', None) - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.duplicate_detection_history_time_window = kwargs.get('duplicate_detection_history_time_window', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.enable_partitioning = kwargs.get('enable_partitioning', None) + super(QueueDescription, self).__init__(**kwargs) + self.lock_duration = kwargs.get('lock_duration', None) self.max_size_in_megabytes = kwargs.get('max_size_in_megabytes', None) self.requires_duplicate_detection = kwargs.get('requires_duplicate_detection', None) + self.requires_session = kwargs.get('requires_session', None) + self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) + self.dead_lettering_on_message_expiration = kwargs.get('dead_lettering_on_message_expiration', None) + self.duplicate_detection_history_time_window = kwargs.get('duplicate_detection_history_time_window', None) + self.max_delivery_count = kwargs.get('max_delivery_count', None) + self.enable_batched_operations = kwargs.get('enable_batched_operations', None) + self.size_in_bytes = kwargs.get('size_in_bytes', None) + self.message_count = kwargs.get('message_count', None) + self.is_anonymous_accessible = kwargs.get('is_anonymous_accessible', None) + self.authorization_rules = kwargs.get('authorization_rules', None) + self.status = kwargs.get('status', None) + self.created_at = kwargs.get('created_at', None) + self.updated_at = kwargs.get('updated_at', None) + self.accessed_at = kwargs.get('accessed_at', None) + self.support_ordering = kwargs.get('support_ordering', None) + self.message_count_details = kwargs.get('message_count_details', None) + self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) + self.enable_partitioning = kwargs.get('enable_partitioning', None) + self.entity_availability_status = kwargs.get('entity_availability_status', None) + self.enable_express = kwargs.get('enable_express', None) + + +class QueueDescriptionEntry(msrest.serialization.Model): + """Represents an entry in the feed when querying queues. + + :param base: Base URL for the query. + :type base: str + :param id: The URL of the GET request. + :type id: str + :param title: The name of the queue. + :type title: object + :param published: The timestamp for when this queue was published. + :type published: ~datetime.datetime + :param updated: The timestamp for when this queue was last updated. + :type updated: ~datetime.datetime + :param author: The author that created this resource. + :type author: ~azure.servicebus.management._generated.models.ResponseAuthor + :param link: The URL for the HTTP request. + :type link: ~azure.servicebus.management._generated.models.ResponseLink + :param content: The QueueDescription. + :type content: ~azure.servicebus.management._generated.models.QueueDescriptionEntryContent + """ + + _attribute_map = { + 'base': {'key': 'base', 'type': 'str', 'xml': {'name': 'base', 'attr': True, 'prefix': 'xml'}}, + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'published': {'key': 'published', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'author': {'key': 'author', 'type': 'ResponseAuthor'}, + 'link': {'key': 'link', 'type': 'ResponseLink'}, + 'content': {'key': 'content', 'type': 'QueueDescriptionEntryContent'}, + } + _xml_map = { + 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + **kwargs + ): + super(QueueDescriptionEntry, self).__init__(**kwargs) + self.base = kwargs.get('base', None) + self.id = kwargs.get('id', None) + self.title = kwargs.get('title', None) + self.published = kwargs.get('published', None) + self.updated = kwargs.get('updated', None) + self.author = kwargs.get('author', None) + self.link = kwargs.get('link', None) + self.content = kwargs.get('content', None) + + +class QueueDescriptionEntryContent(msrest.serialization.Model): + """The QueueDescription. + + :param type: Type of content in queue response. + :type type: str + :param queue_description: Description of a Service Bus queue resource. + :type queue_description: ~azure.servicebus.management._generated.models.QueueDescription + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, + 'queue_description': {'key': 'QueueDescription', 'type': 'QueueDescription'}, + } + _xml_map = { + 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + **kwargs + ): + super(QueueDescriptionEntryContent, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.queue_description = kwargs.get('queue_description', None) + + +class QueueDescriptionFeed(msrest.serialization.Model): + """Response from listing Service Bus queues. + + :param id: URL of the list queues query. + :type id: str + :param title: The entity type for the feed. + :type title: object + :param updated: Datetime of the query. + :type updated: ~datetime.datetime + :param link: Links to paginated response. + :type link: list[~azure.servicebus.management._generated.models.ResponseLink] + :param entry: Queue entries. + :type entry: list[~azure.servicebus.management._generated.models.QueueDescriptionEntry] + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'link': {'key': 'link', 'type': '[ResponseLink]'}, + 'entry': {'key': 'entry', 'type': '[QueueDescriptionEntry]'}, + } + _xml_map = { + 'name': 'feed', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + **kwargs + ): + super(QueueDescriptionFeed, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.title = kwargs.get('title', None) + self.updated = kwargs.get('updated', None) + self.link = kwargs.get('link', None) + self.entry = kwargs.get('entry', None) + + +class ResponseAuthor(msrest.serialization.Model): + """The author that created this resource. + + :param name: The Service Bus namespace. + :type name: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + } + _xml_map = { + 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + **kwargs + ): + super(ResponseAuthor, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + + +class ResponseLink(msrest.serialization.Model): + """The URL for the HTTP request. + + :param href: The URL of the GET request. + :type href: str + :param rel: What the link href is relative to. + :type rel: str + """ + + _attribute_map = { + 'href': {'key': 'href', 'type': 'str', 'xml': {'attr': True}}, + 'rel': {'key': 'rel', 'type': 'str', 'xml': {'attr': True}}, + } + _xml_map = { + 'name': 'link', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + **kwargs + ): + super(ResponseLink, self).__init__(**kwargs) + self.href = kwargs.get('href', None) + self.rel = kwargs.get('rel', None) + + +class RuleDescription(msrest.serialization.Model): + """RuleDescription. + + :param filter: + :type filter: ~azure.servicebus.management._generated.models.RuleFilter + :param action: + :type action: ~azure.servicebus.management._generated.models.RuleAction + :param created_at: The exact time the queue was created. + :type created_at: ~datetime.datetime + :param name: + :type name: str + """ + + _attribute_map = { + 'filter': {'key': 'Filter', 'type': 'RuleFilter'}, + 'action': {'key': 'Action', 'type': 'RuleAction'}, + 'created_at': {'key': 'CreatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'name': {'key': 'Name', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + _xml_map = { + 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' + } + + def __init__( + self, + **kwargs + ): + super(RuleDescription, self).__init__(**kwargs) + self.filter = kwargs.get('filter', None) + self.action = kwargs.get('action', None) + self.created_at = kwargs.get('created_at', None) + self.name = kwargs.get('name', None) + + +class RuleDescriptionEntry(msrest.serialization.Model): + """Represents an entry in the feed when querying rules. + + :param id: The URL of the GET request. + :type id: str + :param title: The name of the rule. + :type title: object + :param published: The timestamp for when this queue was published. + :type published: ~datetime.datetime + :param updated: The timestamp for when this queue was last updated. + :type updated: ~datetime.datetime + :param link: The URL for the HTTP request. + :type link: ~azure.servicebus.management._generated.models.ResponseLink + :param content: The QueueDescription. + :type content: ~azure.servicebus.management._generated.models.RuleDescriptionEntryContent + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'published': {'key': 'published', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'link': {'key': 'link', 'type': 'ResponseLink'}, + 'content': {'key': 'content', 'type': 'RuleDescriptionEntryContent'}, + } + _xml_map = { + 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + **kwargs + ): + super(RuleDescriptionEntry, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.title = kwargs.get('title', None) + self.published = kwargs.get('published', None) + self.updated = kwargs.get('updated', None) + self.link = kwargs.get('link', None) + self.content = kwargs.get('content', None) + + +class RuleDescriptionEntryContent(msrest.serialization.Model): + """The QueueDescription. + + :param type: Type of content in queue response. + :type type: str + :param rule_description: + :type rule_description: ~azure.servicebus.management._generated.models.RuleDescription + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, + 'rule_description': {'key': 'RuleDescription', 'type': 'RuleDescription'}, + } + _xml_map = { + 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + **kwargs + ): + super(RuleDescriptionEntryContent, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.rule_description = kwargs.get('rule_description', None) + + +class RuleDescriptionFeed(msrest.serialization.Model): + """Response from listing Service Bus queues. + + :param id: URL of the list queues query. + :type id: str + :param title: The entity type for the feed. + :type title: object + :param updated: Datetime of the query. + :type updated: ~datetime.datetime + :param link: Links to paginated response. + :type link: list[~azure.servicebus.management._generated.models.ResponseLink] + :param entry: Queue entries. + :type entry: list[~azure.servicebus.management._generated.models.RuleDescriptionEntry] + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'link': {'key': 'link', 'type': '[ResponseLink]'}, + 'entry': {'key': 'entry', 'type': '[RuleDescriptionEntry]'}, + } + _xml_map = { + 'name': 'feed', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + **kwargs + ): + super(RuleDescriptionFeed, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.title = kwargs.get('title', None) + self.updated = kwargs.get('updated', None) + self.link = kwargs.get('link', None) + self.entry = kwargs.get('entry', None) + + +class ServiceBusManagementError(msrest.serialization.Model): + """The error response from Service Bus. + + :param code: The service error code. + :type code: int + :param detail: The service error message. + :type detail: str + """ + + _attribute_map = { + 'code': {'key': 'Code', 'type': 'int'}, + 'detail': {'key': 'Detail', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ServiceBusManagementError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.detail = kwargs.get('detail', None) + + +class SqlFilter(RuleFilter): + """SqlFilter. + + :param type: Constant filled by server. + :type type: str + :param sql_expression: + :type sql_expression: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + 'sql_expression': {'key': 'SqlExpression', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + + def __init__( + self, + **kwargs + ): + super(SqlFilter, self).__init__(**kwargs) + self.type = 'SqlFilter' + self.sql_expression = kwargs.get('sql_expression', None) + + +class SqlRuleAction(RuleAction): + """SqlRuleAction. + + :param type: Constant filled by server. + :type type: str + :param sql_expression: + :type sql_expression: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + 'sql_expression': {'key': 'SqlExpression', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + + def __init__( + self, + **kwargs + ): + super(SqlRuleAction, self).__init__(**kwargs) + self.type = 'SqlRuleAction' + self.sql_expression = kwargs.get('sql_expression', None) + + +class SubscriptionDescription(msrest.serialization.Model): + """Description of a Service Bus queue resource. + + :param lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time + that the message is locked for other receivers. The maximum value for LockDuration is 5 + minutes; the default value is 1 minute. + :type lock_duration: ~datetime.timedelta + :param requires_session: A value that indicates whether the queue supports the concept of + sessions. + :type requires_session: bool + :param default_message_time_to_live: ISO 8601 default message timespan to live value. This is + the duration after which the message expires, starting from when the message is sent to Service + Bus. This is the default value used when TimeToLive is not set on a message itself. + :type default_message_time_to_live: ~datetime.timedelta + :param dead_lettering_on_message_expiration: A value that indicates whether this queue has dead + letter support when a message expires. + :type dead_lettering_on_message_expiration: bool + :param dead_lettering_on_filter_evaluation_exceptions: A value that indicates whether this + queue has dead letter support when a message expires. + :type dead_lettering_on_filter_evaluation_exceptions: bool + :param message_count: The number of messages in the queue. + :type message_count: int + :param max_delivery_count: The maximum delivery count. A message is automatically deadlettered + after this number of deliveries. Default value is 10. + :type max_delivery_count: int + :param enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :type enable_batched_operations: bool + :param status: Status of a Service Bus resource. Possible values include: "Active", "Creating", + "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". + :type status: str or ~azure.servicebus.management._generated.models.EntityStatus + :param forward_to: .. raw:: html + + . + :type forward_to: str + :param created_at: The exact time the queue was created. + :type created_at: ~datetime.datetime + :param updated_at: The exact time a message was updated in the queue. + :type updated_at: ~datetime.datetime + :param accessed_at: Last time a message was sent, or the last time there was a receive request + to this queue. + :type accessed_at: ~datetime.datetime + :param message_count_details: Details about the message counts in queue. + :type message_count_details: ~azure.servicebus.management._generated.models.MessageCountDetails + :param auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the queue is + automatically deleted. The minimum duration is 5 minutes. + :type auto_delete_on_idle: ~datetime.timedelta + :param entity_availability_status: Availability status of the entity. Possible values include: + "Available", "Limited", "Renaming", "Restoring", "Unknown". + :type entity_availability_status: str or + ~azure.servicebus.management._generated.models.EntityAvailabilityStatus + """ + + _attribute_map = { + 'lock_duration': {'key': 'LockDuration', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'requires_session': {'key': 'RequiresSession', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'default_message_time_to_live': {'key': 'DefaultMessageTimeToLive', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'dead_lettering_on_message_expiration': {'key': 'DeadLetteringOnMessageExpiration', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'DeadLetteringOnFilterEvaluationExceptions', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'message_count': {'key': 'MessageCount', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'max_delivery_count': {'key': 'MaxDeliveryCount', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'enable_batched_operations': {'key': 'EnableBatchedOperations', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'status': {'key': 'Status', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'forward_to': {'key': 'ForwardTo', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'created_at': {'key': 'CreatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'updated_at': {'key': 'UpdatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'accessed_at': {'key': 'AccessedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'message_count_details': {'key': 'MessageCountDetails', 'type': 'MessageCountDetails'}, + 'auto_delete_on_idle': {'key': 'AutoDeleteOnIdle', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'entity_availability_status': {'key': 'EntityAvailabilityStatus', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + _xml_map = { + 'name': 'SubscriptionDescription', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' + } + + def __init__( + self, + **kwargs + ): + super(SubscriptionDescription, self).__init__(**kwargs) + self.lock_duration = kwargs.get('lock_duration', None) + self.requires_session = kwargs.get('requires_session', None) + self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) + self.dead_lettering_on_message_expiration = kwargs.get('dead_lettering_on_message_expiration', None) + self.dead_lettering_on_filter_evaluation_exceptions = kwargs.get('dead_lettering_on_filter_evaluation_exceptions', None) + self.message_count = kwargs.get('message_count', None) + self.max_delivery_count = kwargs.get('max_delivery_count', None) + self.enable_batched_operations = kwargs.get('enable_batched_operations', None) + self.status = kwargs.get('status', None) + self.forward_to = kwargs.get('forward_to', None) + self.created_at = kwargs.get('created_at', None) + self.updated_at = kwargs.get('updated_at', None) + self.accessed_at = kwargs.get('accessed_at', None) + self.message_count_details = kwargs.get('message_count_details', None) + self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) + self.entity_availability_status = kwargs.get('entity_availability_status', None) + + +class SubscriptionDescriptionEntry(msrest.serialization.Model): + """Represents an entry in the feed when querying queues. + + :param id: The URL of the GET request. + :type id: str + :param title: The name of the subscription. + :type title: object + :param published: The timestamp for when this queue was published. + :type published: ~datetime.datetime + :param updated: The timestamp for when this queue was last updated. + :type updated: ~datetime.datetime + :param link: The URL for the HTTP request. + :type link: ~azure.servicebus.management._generated.models.ResponseLink + :param content: The QueueDescription. + :type content: + ~azure.servicebus.management._generated.models.SubscriptionDescriptionEntryContent + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'published': {'key': 'published', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'link': {'key': 'link', 'type': 'ResponseLink'}, + 'content': {'key': 'content', 'type': 'SubscriptionDescriptionEntryContent'}, + } + _xml_map = { + 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + **kwargs + ): + super(SubscriptionDescriptionEntry, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.title = kwargs.get('title', None) + self.published = kwargs.get('published', None) + self.updated = kwargs.get('updated', None) + self.link = kwargs.get('link', None) + self.content = kwargs.get('content', None) + + +class SubscriptionDescriptionEntryContent(msrest.serialization.Model): + """The QueueDescription. + + :param type: Type of content in queue response. + :type type: str + :param subscription_description: Description of a Service Bus queue resource. + :type subscription_description: + ~azure.servicebus.management._generated.models.SubscriptionDescription + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, + 'subscription_description': {'key': 'SubscriptionDescription', 'type': 'SubscriptionDescription'}, + } + _xml_map = { + 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + **kwargs + ): + super(SubscriptionDescriptionEntryContent, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.subscription_description = kwargs.get('subscription_description', None) + + +class SubscriptionDescriptionFeed(msrest.serialization.Model): + """Response from listing Service Bus queues. + + :param id: URL of the list queues query. + :type id: str + :param title: The entity type for the feed. + :type title: object + :param updated: Datetime of the query. + :type updated: ~datetime.datetime + :param link: Links to paginated response. + :type link: list[~azure.servicebus.management._generated.models.ResponseLink] + :param entry: Queue entries. + :type entry: list[~azure.servicebus.management._generated.models.SubscriptionDescriptionEntry] + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'link': {'key': 'link', 'type': '[ResponseLink]'}, + 'entry': {'key': 'entry', 'type': '[SubscriptionDescriptionEntry]'}, + } + _xml_map = { + 'name': 'feed', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + **kwargs + ): + super(SubscriptionDescriptionFeed, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.title = kwargs.get('title', None) + self.updated = kwargs.get('updated', None) + self.link = kwargs.get('link', None) + self.entry = kwargs.get('entry', None) + + +class TopicDescription(msrest.serialization.Model): + """Description of a Service Bus topic resource. + + :param default_message_time_to_live: ISO 8601 default message timespan to live value. This is + the duration after which the message expires, starting from when the message is sent to Service + Bus. This is the default value used when TimeToLive is not set on a message itself. + :type default_message_time_to_live: ~datetime.timedelta + :param max_size_in_megabytes: The maximum size of the topic in megabytes, which is the size of + memory allocated for the topic. + :type max_size_in_megabytes: long + :param requires_duplicate_detection: A value indicating if this topic requires duplicate + detection. + :type requires_duplicate_detection: bool + :param duplicate_detection_history_time_window: ISO 8601 timeSpan structure that defines the + duration of the duplicate detection history. The default value is 10 minutes. + :type duplicate_detection_history_time_window: ~datetime.timedelta + :param enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :type enable_batched_operations: bool + :param size_in_bytes: The size of the queue, in bytes. + :type size_in_bytes: int + :param filtering_messages_before_publishing: Filter messages before publishing. + :type filtering_messages_before_publishing: bool + :param is_anonymous_accessible: A value indicating if the resource can be accessed without + authorization. + :type is_anonymous_accessible: bool + :param authorization_rules: Authorization rules for resource. + :type authorization_rules: + list[~azure.servicebus.management._generated.models.AuthorizationRule] + :param status: Status of a Service Bus resource. Possible values include: "Active", "Creating", + "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". + :type status: str or ~azure.servicebus.management._generated.models.EntityStatus + :param created_at: The exact time the queue was created. + :type created_at: ~datetime.datetime + :param updated_at: The exact time a message was updated in the queue. + :type updated_at: ~datetime.datetime + :param accessed_at: Last time a message was sent, or the last time there was a receive request + to this queue. + :type accessed_at: ~datetime.datetime + :param support_ordering: A value that indicates whether the topic supports ordering. + :type support_ordering: bool + :param message_count_details: Details about the message counts in queue. + :type message_count_details: ~azure.servicebus.management._generated.models.MessageCountDetails + :param subscription_count: The number of subscriptions in the topic. + :type subscription_count: int + :param auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the topic is + automatically deleted. The minimum duration is 5 minutes. + :type auto_delete_on_idle: ~datetime.timedelta + :param enable_partitioning: A value that indicates whether the topic is to be partitioned + across multiple message brokers. + :type enable_partitioning: bool + :param entity_availability_status: Availability status of the entity. Possible values include: + "Available", "Limited", "Renaming", "Restoring", "Unknown". + :type entity_availability_status: str or + ~azure.servicebus.management._generated.models.EntityAvailabilityStatus + :param enable_subscription_partitioning: A value that indicates whether the topic's + subscription is to be partitioned. + :type enable_subscription_partitioning: bool + :param enable_express: A value that indicates whether Express Entities are enabled. An express + queue holds a message in memory temporarily before writing it to persistent storage. + :type enable_express: bool + :param user_metadata: Metadata associated with the topic. + :type user_metadata: str + """ + + _attribute_map = { + 'default_message_time_to_live': {'key': 'DefaultMessageTimeToLive', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'max_size_in_megabytes': {'key': 'MaxSizeInMegabytes', 'type': 'long', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'requires_duplicate_detection': {'key': 'RequiresDuplicateDetection', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'duplicate_detection_history_time_window': {'key': 'DuplicateDetectionHistoryTimeWindow', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'enable_batched_operations': {'key': 'EnableBatchedOperations', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'size_in_bytes': {'key': 'SizeInBytes', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'filtering_messages_before_publishing': {'key': 'FilteringMessagesBeforePublishing', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'is_anonymous_accessible': {'key': 'IsAnonymousAccessible', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'authorization_rules': {'key': 'AuthorizationRules', 'type': '[AuthorizationRule]', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'AuthorizationRule', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'status': {'key': 'Status', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'created_at': {'key': 'CreatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'updated_at': {'key': 'UpdatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'accessed_at': {'key': 'AccessedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'support_ordering': {'key': 'SupportOrdering', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'message_count_details': {'key': 'MessageCountDetails', 'type': 'MessageCountDetails'}, + 'subscription_count': {'key': 'SubscriptionCount', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'auto_delete_on_idle': {'key': 'AutoDeleteOnIdle', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'enable_partitioning': {'key': 'EnablePartitioning', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'entity_availability_status': {'key': 'EntityAvailabilityStatus', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'enable_subscription_partitioning': {'key': 'EnableSubscriptionPartitioning', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'enable_express': {'key': 'EnableExpress', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'user_metadata': {'key': 'UserMetadata', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + _xml_map = { + 'name': 'TopicDescription', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' + } + + def __init__( + self, + **kwargs + ): + super(TopicDescription, self).__init__(**kwargs) + self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) + self.max_size_in_megabytes = kwargs.get('max_size_in_megabytes', None) + self.requires_duplicate_detection = kwargs.get('requires_duplicate_detection', None) + self.duplicate_detection_history_time_window = kwargs.get('duplicate_detection_history_time_window', None) + self.enable_batched_operations = kwargs.get('enable_batched_operations', None) + self.size_in_bytes = kwargs.get('size_in_bytes', None) + self.filtering_messages_before_publishing = kwargs.get('filtering_messages_before_publishing', None) + self.is_anonymous_accessible = kwargs.get('is_anonymous_accessible', None) + self.authorization_rules = kwargs.get('authorization_rules', None) self.status = kwargs.get('status', None) + self.created_at = kwargs.get('created_at', None) + self.updated_at = kwargs.get('updated_at', None) + self.accessed_at = kwargs.get('accessed_at', None) self.support_ordering = kwargs.get('support_ordering', None) + self.message_count_details = kwargs.get('message_count_details', None) + self.subscription_count = kwargs.get('subscription_count', None) + self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) + self.enable_partitioning = kwargs.get('enable_partitioning', None) + self.entity_availability_status = kwargs.get('entity_availability_status', None) + self.enable_subscription_partitioning = kwargs.get('enable_subscription_partitioning', None) + self.enable_express = kwargs.get('enable_express', None) self.user_metadata = kwargs.get('user_metadata', None) + + +class TopicDescriptionEntry(msrest.serialization.Model): + """Represents an entry in the feed when querying topics. + + :param base: Base URL for the query. + :type base: str + :param id: The URL of the GET request. + :type id: str + :param title: The name of the queue. + :type title: object + :param published: The timestamp for when this queue was published. + :type published: ~datetime.datetime + :param updated: The timestamp for when this queue was last updated. + :type updated: ~datetime.datetime + :param author: The author that created this resource. + :type author: ~azure.servicebus.management._generated.models.ResponseAuthor + :param link: The URL for the HTTP request. + :type link: ~azure.servicebus.management._generated.models.ResponseLink + :param content: The QueueDescription. + :type content: ~azure.servicebus.management._generated.models.TopicDescriptionEntryContent + """ + + _attribute_map = { + 'base': {'key': 'base', 'type': 'str', 'xml': {'name': 'base', 'attr': True, 'prefix': 'xml'}}, + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'published': {'key': 'published', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'author': {'key': 'author', 'type': 'ResponseAuthor'}, + 'link': {'key': 'link', 'type': 'ResponseLink'}, + 'content': {'key': 'content', 'type': 'TopicDescriptionEntryContent'}, + } + _xml_map = { + 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + **kwargs + ): + super(TopicDescriptionEntry, self).__init__(**kwargs) + self.base = kwargs.get('base', None) + self.id = kwargs.get('id', None) + self.title = kwargs.get('title', None) + self.published = kwargs.get('published', None) + self.updated = kwargs.get('updated', None) + self.author = kwargs.get('author', None) + self.link = kwargs.get('link', None) + self.content = kwargs.get('content', None) + + +class TopicDescriptionEntryContent(msrest.serialization.Model): + """The QueueDescription. + + :param type: Type of content in queue response. + :type type: str + :param topic_description: Description of a Service Bus topic resource. + :type topic_description: ~azure.servicebus.management._generated.models.TopicDescription + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, + 'topic_description': {'key': 'TopicDescription', 'type': 'TopicDescription'}, + } + _xml_map = { + 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + **kwargs + ): + super(TopicDescriptionEntryContent, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.topic_description = kwargs.get('topic_description', None) + + +class TopicDescriptionFeed(msrest.serialization.Model): + """Response from listing Service Bus queues. + + :param id: URL of the list queues query. + :type id: str + :param title: The entity type for the feed. + :type title: object + :param updated: Datetime of the query. + :type updated: ~datetime.datetime + :param link: Links to paginated response. + :type link: list[~azure.servicebus.management._generated.models.ResponseLink] + :param entry: Topic entries. + :type entry: list[~azure.servicebus.management._generated.models.TopicDescriptionEntry] + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'link': {'key': 'link', 'type': '[ResponseLink]'}, + 'entry': {'key': 'entry', 'type': '[TopicDescriptionEntry]'}, + } + _xml_map = { + 'name': 'feed', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + **kwargs + ): + super(TopicDescriptionFeed, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.title = kwargs.get('title', None) + self.updated = kwargs.get('updated', None) + self.link = kwargs.get('link', None) + self.entry = kwargs.get('entry', None) + + +class TrueFilter(RuleFilter): + """TrueFilter. + + :param type: Constant filled by server. + :type type: str + :param sql_expression: + :type sql_expression: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + 'sql_expression': {'key': 'SqlExpression', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + + def __init__( + self, + **kwargs + ): + super(TrueFilter, self).__init__(**kwargs) + self.type = 'TrueFilter' + self.sql_expression = kwargs.get('sql_expression', "1 = 1") diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_models_py3.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_models_py3.py index e2288a5862aa..25a40c7a1cc4 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_models_py3.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_models_py3.py @@ -79,6 +79,100 @@ def __init__( self.secondary_key = secondary_key +class RuleFilter(msrest.serialization.Model): + """RuleFilter. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: CorrelationFilter, FalseFilter, SqlFilter, TrueFilter. + + :param type: Constant filled by server. + :type type: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + } + + _subtype_map = { + 'type': {'CorrelationFilter': 'CorrelationFilter', 'FalseFilter': 'FalseFilter', 'SqlFilter': 'SqlFilter', 'TrueFilter': 'TrueFilter'} + } + _xml_map = { + 'name': 'Filter', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' + } + + def __init__( + self, + **kwargs + ): + super(RuleFilter, self).__init__(**kwargs) + self.type: Optional[str] = None + + +class CorrelationFilter(RuleFilter): + """CorrelationFilter. + + :param type: Constant filled by server. + :type type: str + :param correlation_id: + :type correlation_id: str + :param message_id: + :type message_id: str + :param to: + :type to: str + :param reply_to: + :type reply_to: str + :param label: + :type label: str + :param session_id: + :type session_id: str + :param reply_to_session_id: + :type reply_to_session_id: str + :param content_type: + :type content_type: str + :param properties: + :type properties: list[~azure.servicebus.management._generated.models.KeyValue] + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + 'correlation_id': {'key': 'CorrelationId', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'message_id': {'key': 'MessageId', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'to': {'key': 'To', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'reply_to': {'key': 'ReplyTo', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'label': {'key': 'Label', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'session_id': {'key': 'SessionId', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'reply_to_session_id': {'key': 'ReplyToSessionId', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'content_type': {'key': 'ContentType', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'properties': {'key': 'Properties', 'type': '[KeyValue]', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'KeyValueOfstringanyType', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + + def __init__( + self, + *, + correlation_id: Optional[str] = None, + message_id: Optional[str] = None, + to: Optional[str] = None, + reply_to: Optional[str] = None, + label: Optional[str] = None, + session_id: Optional[str] = None, + reply_to_session_id: Optional[str] = None, + content_type: Optional[str] = None, + properties: Optional[List["KeyValue"]] = None, + **kwargs + ): + super(CorrelationFilter, self).__init__(**kwargs) + self.type: str = 'CorrelationFilter' + self.correlation_id = correlation_id + self.message_id = message_id + self.to = to + self.reply_to = reply_to + self.label = label + self.session_id = session_id + self.reply_to_session_id = reply_to_session_id + self.content_type = content_type + self.properties = properties + + class CreateQueueBody(msrest.serialization.Model): """The request body for creating a queue. @@ -132,6 +226,113 @@ def __init__( self.queue_description = queue_description +class CreateRuleBody(msrest.serialization.Model): + """The request body for creating a topic. + + :param content: RuleDescription for the new Rule. + :type content: ~azure.servicebus.management._generated.models.CreateRuleBodyContent + """ + + _attribute_map = { + 'content': {'key': 'content', 'type': 'CreateRuleBodyContent'}, + } + _xml_map = { + 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + *, + content: Optional["CreateRuleBodyContent"] = None, + **kwargs + ): + super(CreateRuleBody, self).__init__(**kwargs) + self.content = content + + +class CreateRuleBodyContent(msrest.serialization.Model): + """RuleDescription for the new Rule. + + :param type: MIME type of content. + :type type: str + :param rule_description: Rule information to create. + :type rule_description: ~azure.servicebus.management._generated.models.RuleDescription + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, + 'rule_description': {'key': 'RuleDescription', 'type': 'RuleDescription'}, + } + _xml_map = { + 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + *, + type: Optional[str] = "application/xml", + rule_description: Optional["RuleDescription"] = None, + **kwargs + ): + super(CreateRuleBodyContent, self).__init__(**kwargs) + self.type = type + self.rule_description = rule_description + + +class CreateSubscriptionBody(msrest.serialization.Model): + """The request body for creating a topic. + + :param content: TopicDescription for the new topic. + :type content: ~azure.servicebus.management._generated.models.CreateSubscriptionBodyContent + """ + + _attribute_map = { + 'content': {'key': 'content', 'type': 'CreateSubscriptionBodyContent'}, + } + _xml_map = { + 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + *, + content: Optional["CreateSubscriptionBodyContent"] = None, + **kwargs + ): + super(CreateSubscriptionBody, self).__init__(**kwargs) + self.content = content + + +class CreateSubscriptionBodyContent(msrest.serialization.Model): + """TopicDescription for the new topic. + + :param type: MIME type of content. + :type type: str + :param subscription_description: Topic information to create. + :type subscription_description: + ~azure.servicebus.management._generated.models.SubscriptionDescription + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, + 'subscription_description': {'key': 'SubscriptionDescription', 'type': 'SubscriptionDescription'}, + } + _xml_map = { + 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + *, + type: Optional[str] = "application/xml", + subscription_description: Optional["SubscriptionDescription"] = None, + **kwargs + ): + super(CreateSubscriptionBodyContent, self).__init__(**kwargs) + self.type = type + self.subscription_description = subscription_description + + class CreateTopicBody(msrest.serialization.Model): """The request body for creating a topic. @@ -185,6 +386,108 @@ def __init__( self.topic_description = topic_description +class RuleAction(msrest.serialization.Model): + """RuleAction. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: EmptyRuleAction, SqlRuleAction. + + :param type: Constant filled by server. + :type type: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + } + + _subtype_map = { + 'type': {'EmptyRuleAction': 'EmptyRuleAction', 'SqlRuleAction': 'SqlRuleAction'} + } + _xml_map = { + 'name': 'Action', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' + } + + def __init__( + self, + **kwargs + ): + super(RuleAction, self).__init__(**kwargs) + self.type: Optional[str] = None + + +class EmptyRuleAction(RuleAction): + """EmptyRuleAction. + + :param type: Constant filled by server. + :type type: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + } + + def __init__( + self, + **kwargs + ): + super(EmptyRuleAction, self).__init__(**kwargs) + self.type: str = 'EmptyRuleAction' + + +class FalseFilter(RuleFilter): + """FalseFilter. + + :param type: Constant filled by server. + :type type: str + :param sql_expression: + :type sql_expression: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + 'sql_expression': {'key': 'SqlExpression', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + + def __init__( + self, + *, + sql_expression: Optional[str] = "1 != 1", + **kwargs + ): + super(FalseFilter, self).__init__(**kwargs) + self.type: str = 'FalseFilter' + self.sql_expression = sql_expression + + +class KeyValue(msrest.serialization.Model): + """KeyValue. + + :param key: + :type key: str + :param value: + :type value: str + """ + + _attribute_map = { + 'key': {'key': 'Key', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'value': {'key': 'Value', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + _xml_map = { + 'name': 'KeyValueOfstringanyType', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' + } + + def __init__( + self, + *, + key: Optional[str] = None, + value: Optional[str] = None, + **kwargs + ): + super(KeyValue, self).__init__(**kwargs) + self.key = key + self.value = value + + class MessageCountDetails(msrest.serialization.Model): """Details about the message counts in queue. @@ -230,101 +533,235 @@ def __init__( self.transfer_message_count = transfer_message_count -class QueueDescription(msrest.serialization.Model): - """Description of a Service Bus queue resource. +class NamespaceProperties(msrest.serialization.Model): + """The metadata related to a Service Bus namespace. - :param authorization_rules: Authorization rules for resource. - :type authorization_rules: - list[~azure.servicebus.management._generated.models.AuthorizationRule] - :param auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the queue is - automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: ~datetime.timedelta - :param created_at: The exact time the queue was created. - :type created_at: ~datetime.datetime - :param dead_lettering_on_message_expiration: A value that indicates whether this queue has dead - letter support when a message expires. - :type dead_lettering_on_message_expiration: bool - :param default_message_time_to_live: ISO 8601 default message timespan to live value. This is - the duration after which the message expires, starting from when the message is sent to Service - Bus. This is the default value used when TimeToLive is not set on a message itself. - :type default_message_time_to_live: ~datetime.timedelta - :param duplicate_detection_history_time_window: ISO 8601 timeSpan structure that defines the - duration of the duplicate detection history. The default value is 10 minutes. - :type duplicate_detection_history_time_window: ~datetime.timedelta - :param entity_availability_status: Availibility status of the entity. Possible values include: - "Available", "Limited", "Renaming", "Restoring", "Unknown". - :type entity_availability_status: str or - ~azure.servicebus.management._generated.models.EntityAvailabilityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :param enable_express: A value that indicates whether Express Entities are enabled. An express - queue holds a message in memory temporarily before writing it to persistent storage. - :type enable_express: bool - :param enable_partitioning: A value that indicates whether the queue is to be partitioned - across multiple message brokers. - :type enable_partitioning: bool - :param is_anonymous_accessible: A value indicating if the resource can be accessed without - authorization. - :type is_anonymous_accessible: bool - :param lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time - that the message is locked for other receivers. The maximum value for LockDuration is 5 - minutes; the default value is 1 minute. - :type lock_duration: ~datetime.timedelta - :param max_delivery_count: The maximum delivery count. A message is automatically deadlettered - after this number of deliveries. Default value is 10. - :type max_delivery_count: int - :param max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size of - memory allocated for the queue. - :type max_size_in_megabytes: int - :param requires_duplicate_detection: A value indicating if this queue requires duplicate - detection. - :type requires_duplicate_detection: bool - :param requires_session: A value that indicates whether the queue supports the concept of - sessions. - :type requires_session: bool - :param status: Status of a Service Bus resource. Possible values include: "Active", "Creating", - "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". - :type status: str or ~azure.servicebus.management._generated.models.EntityStatus - :param support_ordering: A value that indicates whether the queue supports ordering. - :type support_ordering: bool - :param accessed_at: Last time a message was sent, or the last time there was a receive request - to this queue. - :type accessed_at: ~datetime.datetime - :param updated_at: The exact time a message was updated in the queue. - :type updated_at: ~datetime.datetime - :param size_in_bytes: The size of the queue, in bytes. - :type size_in_bytes: int - :param message_count: The number of messages in the queue. - :type message_count: int - :param message_count_details: Details about the message counts in queue. - :type message_count_details: ~azure.servicebus.management._generated.models.MessageCountDetails + :param alias: Alias for the geo-disaster recovery Service Bus namespace. + :type alias: str + :param created_time: The exact time the namespace was created. + :type created_time: ~datetime.datetime + :param messaging_sku: The SKU for the messaging entity. Possible values include: "Basic", + "Standard", "Premium". + :type messaging_sku: str or ~azure.servicebus.management._generated.models.MessagingSku + :param messaging_units: The number of messaging units allocated to the namespace. + :type messaging_units: int + :param modified_time: The exact time the namespace was last modified. + :type modified_time: ~datetime.datetime + :param name: Name of the namespace. + :type name: str + :param namespace_type: The type of entities the namespace can contain. Possible values include: + "Messaging", "NotificationHub", "Mixed", "EventHub", "Relay". + :type namespace_type: str or ~azure.servicebus.management._generated.models.NamespaceType """ _attribute_map = { - 'authorization_rules': {'key': 'AuthorizationRules', 'type': '[AuthorizationRule]', 'xml': {'name': 'AuthorizationRules', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'AuthorizationRule', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'auto_delete_on_idle': {'key': 'AutoDeleteOnIdle', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'created_at': {'key': 'CreatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'dead_lettering_on_message_expiration': {'key': 'DeadLetteringOnMessageExpiration', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'default_message_time_to_live': {'key': 'DefaultMessageTimeToLive', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'duplicate_detection_history_time_window': {'key': 'DuplicateDetectionHistoryTimeWindow', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'entity_availability_status': {'key': 'EntityAvailabilityStatus', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_batched_operations': {'key': 'EnableBatchedOperations', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_express': {'key': 'EnableExpress', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_partitioning': {'key': 'EnablePartitioning', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'is_anonymous_accessible': {'key': 'IsAnonymousAccessible', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'lock_duration': {'key': 'LockDuration', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_delivery_count': {'key': 'MaxDeliveryCount', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_size_in_megabytes': {'key': 'MaxSizeInMegabytes', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'alias': {'key': 'Alias', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'created_time': {'key': 'CreatedTime', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'messaging_sku': {'key': 'MessagingSku', 'type': 'str', 'xml': {'name': 'MessagingSKU', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'messaging_units': {'key': 'MessagingUnits', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'modified_time': {'key': 'ModifiedTime', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'name': {'key': 'Name', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'namespace_type': {'key': 'NamespaceType', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + _xml_map = { + 'name': 'NamespaceInfo', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' + } + + def __init__( + self, + *, + alias: Optional[str] = None, + created_time: Optional[datetime.datetime] = None, + messaging_sku: Optional[Union[str, "MessagingSku"]] = None, + messaging_units: Optional[int] = None, + modified_time: Optional[datetime.datetime] = None, + name: Optional[str] = None, + namespace_type: Optional[Union[str, "NamespaceType"]] = None, + **kwargs + ): + super(NamespaceProperties, self).__init__(**kwargs) + self.alias = alias + self.created_time = created_time + self.messaging_sku = messaging_sku + self.messaging_units = messaging_units + self.modified_time = modified_time + self.name = name + self.namespace_type = namespace_type + + +class NamespacePropertiesEntry(msrest.serialization.Model): + """Represents an entry in the feed when querying namespace info. + + :param id: The URL of the GET request. + :type id: str + :param title: The name of the namespace. + :type title: object + :param updated: The timestamp for when this namespace was last updated. + :type updated: ~datetime.datetime + :param author: The author that created this resource. + :type author: ~azure.servicebus.management._generated.models.ResponseAuthor + :param link: The URL for the HTTP request. + :type link: ~azure.servicebus.management._generated.models.ResponseLink + :param content: Information about the namespace. + :type content: ~azure.servicebus.management._generated.models.NamespacePropertiesEntryContent + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'author': {'key': 'author', 'type': 'ResponseAuthor'}, + 'link': {'key': 'link', 'type': 'ResponseLink'}, + 'content': {'key': 'content', 'type': 'NamespacePropertiesEntryContent'}, + } + _xml_map = { + 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + *, + id: Optional[str] = None, + title: Optional[object] = None, + updated: Optional[datetime.datetime] = None, + author: Optional["ResponseAuthor"] = None, + link: Optional["ResponseLink"] = None, + content: Optional["NamespacePropertiesEntryContent"] = None, + **kwargs + ): + super(NamespacePropertiesEntry, self).__init__(**kwargs) + self.id = id + self.title = title + self.updated = updated + self.author = author + self.link = link + self.content = content + + +class NamespacePropertiesEntryContent(msrest.serialization.Model): + """Information about the namespace. + + :param type: Type of content in namespace info response. + :type type: str + :param namespace_properties: The metadata related to a Service Bus namespace. + :type namespace_properties: ~azure.servicebus.management._generated.models.NamespaceProperties + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, + 'namespace_properties': {'key': 'NamespaceProperties', 'type': 'NamespaceProperties'}, + } + _xml_map = { + 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + *, + type: Optional[str] = None, + namespace_properties: Optional["NamespaceProperties"] = None, + **kwargs + ): + super(NamespacePropertiesEntryContent, self).__init__(**kwargs) + self.type = type + self.namespace_properties = namespace_properties + + +class QueueDescription(msrest.serialization.Model): + """Description of a Service Bus queue resource. + + :param lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time + that the message is locked for other receivers. The maximum value for LockDuration is 5 + minutes; the default value is 1 minute. + :type lock_duration: ~datetime.timedelta + :param max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size of + memory allocated for the queue. + :type max_size_in_megabytes: int + :param requires_duplicate_detection: A value indicating if this queue requires duplicate + detection. + :type requires_duplicate_detection: bool + :param requires_session: A value that indicates whether the queue supports the concept of + sessions. + :type requires_session: bool + :param default_message_time_to_live: ISO 8601 default message timespan to live value. This is + the duration after which the message expires, starting from when the message is sent to Service + Bus. This is the default value used when TimeToLive is not set on a message itself. + :type default_message_time_to_live: ~datetime.timedelta + :param dead_lettering_on_message_expiration: A value that indicates whether this queue has dead + letter support when a message expires. + :type dead_lettering_on_message_expiration: bool + :param duplicate_detection_history_time_window: ISO 8601 timeSpan structure that defines the + duration of the duplicate detection history. The default value is 10 minutes. + :type duplicate_detection_history_time_window: ~datetime.timedelta + :param max_delivery_count: The maximum delivery count. A message is automatically deadlettered + after this number of deliveries. Default value is 10. + :type max_delivery_count: int + :param enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :type enable_batched_operations: bool + :param size_in_bytes: The size of the queue, in bytes. + :type size_in_bytes: int + :param message_count: The number of messages in the queue. + :type message_count: int + :param is_anonymous_accessible: A value indicating if the resource can be accessed without + authorization. + :type is_anonymous_accessible: bool + :param authorization_rules: Authorization rules for resource. + :type authorization_rules: + list[~azure.servicebus.management._generated.models.AuthorizationRule] + :param status: Status of a Service Bus resource. Possible values include: "Active", "Creating", + "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". + :type status: str or ~azure.servicebus.management._generated.models.EntityStatus + :param created_at: The exact time the queue was created. + :type created_at: ~datetime.datetime + :param updated_at: The exact time a message was updated in the queue. + :type updated_at: ~datetime.datetime + :param accessed_at: Last time a message was sent, or the last time there was a receive request + to this queue. + :type accessed_at: ~datetime.datetime + :param support_ordering: A value that indicates whether the queue supports ordering. + :type support_ordering: bool + :param message_count_details: Details about the message counts in queue. + :type message_count_details: ~azure.servicebus.management._generated.models.MessageCountDetails + :param auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the queue is + automatically deleted. The minimum duration is 5 minutes. + :type auto_delete_on_idle: ~datetime.timedelta + :param enable_partitioning: A value that indicates whether the queue is to be partitioned + across multiple message brokers. + :type enable_partitioning: bool + :param entity_availability_status: Availability status of the entity. Possible values include: + "Available", "Limited", "Renaming", "Restoring", "Unknown". + :type entity_availability_status: str or + ~azure.servicebus.management._generated.models.EntityAvailabilityStatus + :param enable_express: A value that indicates whether Express Entities are enabled. An express + queue holds a message in memory temporarily before writing it to persistent storage. + :type enable_express: bool + """ + + _attribute_map = { + 'lock_duration': {'key': 'LockDuration', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'max_size_in_megabytes': {'key': 'MaxSizeInMegabytes', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, 'requires_duplicate_detection': {'key': 'RequiresDuplicateDetection', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, 'requires_session': {'key': 'RequiresSession', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'status': {'key': 'Status', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'support_ordering': {'key': 'SupportOrdering', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'accessed_at': {'key': 'AccessedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'updated_at': {'key': 'UpdatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'default_message_time_to_live': {'key': 'DefaultMessageTimeToLive', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'dead_lettering_on_message_expiration': {'key': 'DeadLetteringOnMessageExpiration', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'duplicate_detection_history_time_window': {'key': 'DuplicateDetectionHistoryTimeWindow', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'max_delivery_count': {'key': 'MaxDeliveryCount', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'enable_batched_operations': {'key': 'EnableBatchedOperations', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, 'size_in_bytes': {'key': 'SizeInBytes', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, 'message_count': {'key': 'MessageCount', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'is_anonymous_accessible': {'key': 'IsAnonymousAccessible', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'authorization_rules': {'key': 'AuthorizationRules', 'type': '[AuthorizationRule]', 'xml': {'name': 'AuthorizationRules', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'AuthorizationRule', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'status': {'key': 'Status', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'created_at': {'key': 'CreatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'updated_at': {'key': 'UpdatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'accessed_at': {'key': 'AccessedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'support_ordering': {'key': 'SupportOrdering', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, 'message_count_details': {'key': 'MessageCountDetails', 'type': 'MessageCountDetails'}, + 'auto_delete_on_idle': {'key': 'AutoDeleteOnIdle', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'enable_partitioning': {'key': 'EnablePartitioning', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'entity_availability_status': {'key': 'EntityAvailabilityStatus', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'enable_express': {'key': 'EnableExpress', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, } _xml_map = { 'name': 'QueueDescription', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' @@ -333,55 +770,55 @@ class QueueDescription(msrest.serialization.Model): def __init__( self, *, - authorization_rules: Optional[List["AuthorizationRule"]] = None, - auto_delete_on_idle: Optional[datetime.timedelta] = None, - created_at: Optional[datetime.datetime] = None, - dead_lettering_on_message_expiration: Optional[bool] = None, - default_message_time_to_live: Optional[datetime.timedelta] = None, - duplicate_detection_history_time_window: Optional[datetime.timedelta] = None, - entity_availability_status: Optional[Union[str, "EntityAvailabilityStatus"]] = None, - enable_batched_operations: Optional[bool] = None, - enable_express: Optional[bool] = None, - enable_partitioning: Optional[bool] = None, - is_anonymous_accessible: Optional[bool] = None, lock_duration: Optional[datetime.timedelta] = None, - max_delivery_count: Optional[int] = None, max_size_in_megabytes: Optional[int] = None, requires_duplicate_detection: Optional[bool] = None, requires_session: Optional[bool] = None, - status: Optional[Union[str, "EntityStatus"]] = None, - support_ordering: Optional[bool] = None, - accessed_at: Optional[datetime.datetime] = None, - updated_at: Optional[datetime.datetime] = None, + default_message_time_to_live: Optional[datetime.timedelta] = None, + dead_lettering_on_message_expiration: Optional[bool] = None, + duplicate_detection_history_time_window: Optional[datetime.timedelta] = None, + max_delivery_count: Optional[int] = None, + enable_batched_operations: Optional[bool] = None, size_in_bytes: Optional[int] = None, message_count: Optional[int] = None, + is_anonymous_accessible: Optional[bool] = None, + authorization_rules: Optional[List["AuthorizationRule"]] = None, + status: Optional[Union[str, "EntityStatus"]] = None, + created_at: Optional[datetime.datetime] = None, + updated_at: Optional[datetime.datetime] = None, + accessed_at: Optional[datetime.datetime] = None, + support_ordering: Optional[bool] = None, message_count_details: Optional["MessageCountDetails"] = None, + auto_delete_on_idle: Optional[datetime.timedelta] = None, + enable_partitioning: Optional[bool] = None, + entity_availability_status: Optional[Union[str, "EntityAvailabilityStatus"]] = None, + enable_express: Optional[bool] = None, **kwargs ): super(QueueDescription, self).__init__(**kwargs) - self.authorization_rules = authorization_rules - self.auto_delete_on_idle = auto_delete_on_idle - self.created_at = created_at - self.dead_lettering_on_message_expiration = dead_lettering_on_message_expiration - self.default_message_time_to_live = default_message_time_to_live - self.duplicate_detection_history_time_window = duplicate_detection_history_time_window - self.entity_availability_status = entity_availability_status - self.enable_batched_operations = enable_batched_operations - self.enable_express = enable_express - self.enable_partitioning = enable_partitioning - self.is_anonymous_accessible = is_anonymous_accessible self.lock_duration = lock_duration - self.max_delivery_count = max_delivery_count self.max_size_in_megabytes = max_size_in_megabytes self.requires_duplicate_detection = requires_duplicate_detection self.requires_session = requires_session - self.status = status - self.support_ordering = support_ordering - self.accessed_at = accessed_at - self.updated_at = updated_at + self.default_message_time_to_live = default_message_time_to_live + self.dead_lettering_on_message_expiration = dead_lettering_on_message_expiration + self.duplicate_detection_history_time_window = duplicate_detection_history_time_window + self.max_delivery_count = max_delivery_count + self.enable_batched_operations = enable_batched_operations self.size_in_bytes = size_in_bytes self.message_count = message_count + self.is_anonymous_accessible = is_anonymous_accessible + self.authorization_rules = authorization_rules + self.status = status + self.created_at = created_at + self.updated_at = updated_at + self.accessed_at = accessed_at + self.support_ordering = support_ordering self.message_count_details = message_count_details + self.auto_delete_on_idle = auto_delete_on_idle + self.enable_partitioning = enable_partitioning + self.entity_availability_status = entity_availability_status + self.enable_express = enable_express class QueueDescriptionEntry(msrest.serialization.Model): @@ -392,7 +829,7 @@ class QueueDescriptionEntry(msrest.serialization.Model): :param id: The URL of the GET request. :type id: str :param title: The name of the queue. - :type title: ~azure.servicebus.management._generated.models.ResponseTitle + :type title: object :param published: The timestamp for when this queue was published. :type published: ~datetime.datetime :param updated: The timestamp for when this queue was last updated. @@ -407,10 +844,10 @@ class QueueDescriptionEntry(msrest.serialization.Model): _attribute_map = { 'base': {'key': 'base', 'type': 'str', 'xml': {'name': 'base', 'attr': True, 'prefix': 'xml'}}, - 'id': {'key': 'id', 'type': 'str'}, - 'title': {'key': 'title', 'type': 'ResponseTitle'}, - 'published': {'key': 'published', 'type': 'iso-8601'}, - 'updated': {'key': 'updated', 'type': 'iso-8601'}, + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'published': {'key': 'published', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, 'author': {'key': 'author', 'type': 'ResponseAuthor'}, 'link': {'key': 'link', 'type': 'ResponseLink'}, 'content': {'key': 'content', 'type': 'QueueDescriptionEntryContent'}, @@ -424,7 +861,7 @@ def __init__( *, base: Optional[str] = None, id: Optional[str] = None, - title: Optional["ResponseTitle"] = None, + title: Optional[object] = None, published: Optional[datetime.datetime] = None, updated: Optional[datetime.datetime] = None, author: Optional["ResponseAuthor"] = None, @@ -456,6 +893,9 @@ class QueueDescriptionEntryContent(msrest.serialization.Model): 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, 'queue_description': {'key': 'QueueDescription', 'type': 'QueueDescription'}, } + _xml_map = { + 'ns': 'http://www.w3.org/2005/Atom' + } def __init__( self, @@ -475,7 +915,7 @@ class QueueDescriptionFeed(msrest.serialization.Model): :param id: URL of the list queues query. :type id: str :param title: The entity type for the feed. - :type title: str + :type title: object :param updated: Datetime of the query. :type updated: ~datetime.datetime :param link: Links to paginated response. @@ -485,9 +925,9 @@ class QueueDescriptionFeed(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'title': {'key': 'title', 'type': 'str'}, - 'updated': {'key': 'updated', 'type': 'iso-8601'}, + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, 'link': {'key': 'link', 'type': '[ResponseLink]'}, 'entry': {'key': 'entry', 'type': '[QueueDescriptionEntry]'}, } @@ -499,7 +939,7 @@ def __init__( self, *, id: Optional[str] = None, - title: Optional[str] = None, + title: Optional[object] = None, updated: Optional[datetime.datetime] = None, link: Optional[List["ResponseLink"]] = None, entry: Optional[List["QueueDescriptionEntry"]] = None, @@ -513,160 +953,218 @@ def __init__( self.entry = entry -class QueueDescriptionResponse(msrest.serialization.Model): - """The response from a Queue_Get operation. +class ResponseAuthor(msrest.serialization.Model): + """The author that created this resource. - :param id: The URL of the GET request. - :type id: str - :param title: The name of the queue. - :type title: str - :param published: The timestamp for when this queue was published. - :type published: str - :param updated: The timestamp for when this queue was last updated. - :type updated: str - :param author: The author that created this resource. - :type author: ~azure.servicebus.management._generated.models.ResponseAuthor - :param link: The URL for the HTTP request. - :type link: ~azure.servicebus.management._generated.models.ResponseLink - :param content: Contents of a Queue_Get response. - :type content: ~azure.servicebus.management._generated.models.QueueDescriptionResponseContent + :param name: The Service Bus namespace. + :type name: str """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'title': {'key': 'title', 'type': 'str'}, - 'published': {'key': 'published', 'type': 'str'}, - 'updated': {'key': 'updated', 'type': 'str'}, - 'author': {'key': 'author', 'type': 'ResponseAuthor'}, - 'link': {'key': 'link', 'type': 'ResponseLink'}, - 'content': {'key': 'content', 'type': 'QueueDescriptionResponseContent'}, + 'name': {'key': 'name', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, } _xml_map = { - 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' + 'ns': 'http://www.w3.org/2005/Atom' } def __init__( self, *, - id: Optional[str] = None, - title: Optional[str] = None, - published: Optional[str] = None, - updated: Optional[str] = None, - author: Optional["ResponseAuthor"] = None, - link: Optional["ResponseLink"] = None, - content: Optional["QueueDescriptionResponseContent"] = None, + name: Optional[str] = None, **kwargs ): - super(QueueDescriptionResponse, self).__init__(**kwargs) - self.id = id - self.title = title - self.published = published - self.updated = updated - self.author = author - self.link = link - self.content = content + super(ResponseAuthor, self).__init__(**kwargs) + self.name = name -class QueueDescriptionResponseContent(msrest.serialization.Model): - """Contents of a Queue_Get response. +class ResponseLink(msrest.serialization.Model): + """The URL for the HTTP request. - :param type: Type of content in queue response. - :type type: str - :param queue_description: Description of a Service Bus queue resource. - :type queue_description: ~azure.servicebus.management._generated.models.QueueDescription + :param href: The URL of the GET request. + :type href: str + :param rel: What the link href is relative to. + :type rel: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, - 'queue_description': {'key': 'QueueDescription', 'type': 'QueueDescription'}, + 'href': {'key': 'href', 'type': 'str', 'xml': {'attr': True}}, + 'rel': {'key': 'rel', 'type': 'str', 'xml': {'attr': True}}, + } + _xml_map = { + 'name': 'link', 'ns': 'http://www.w3.org/2005/Atom' } def __init__( self, *, - type: Optional[str] = None, - queue_description: Optional["QueueDescription"] = None, + href: Optional[str] = None, + rel: Optional[str] = None, **kwargs ): - super(QueueDescriptionResponseContent, self).__init__(**kwargs) - self.type = type - self.queue_description = queue_description + super(ResponseLink, self).__init__(**kwargs) + self.href = href + self.rel = rel -class ResponseAuthor(msrest.serialization.Model): - """The author that created this resource. +class RuleDescription(msrest.serialization.Model): + """RuleDescription. - :param name: The Service Bus namespace. + :param filter: + :type filter: ~azure.servicebus.management._generated.models.RuleFilter + :param action: + :type action: ~azure.servicebus.management._generated.models.RuleAction + :param created_at: The exact time the queue was created. + :type created_at: ~datetime.datetime + :param name: :type name: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + 'filter': {'key': 'Filter', 'type': 'RuleFilter'}, + 'action': {'key': 'Action', 'type': 'RuleAction'}, + 'created_at': {'key': 'CreatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'name': {'key': 'Name', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + _xml_map = { + 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' } def __init__( self, *, + filter: Optional["RuleFilter"] = None, + action: Optional["RuleAction"] = None, + created_at: Optional[datetime.datetime] = None, name: Optional[str] = None, **kwargs ): - super(ResponseAuthor, self).__init__(**kwargs) + super(RuleDescription, self).__init__(**kwargs) + self.filter = filter + self.action = action + self.created_at = created_at self.name = name -class ResponseLink(msrest.serialization.Model): - """The URL for the HTTP request. +class RuleDescriptionEntry(msrest.serialization.Model): + """Represents an entry in the feed when querying rules. - :param href: The URL of the GET request. - :type href: str - :param rel: What the link href is relative to. - :type rel: str + :param id: The URL of the GET request. + :type id: str + :param title: The name of the rule. + :type title: object + :param published: The timestamp for when this queue was published. + :type published: ~datetime.datetime + :param updated: The timestamp for when this queue was last updated. + :type updated: ~datetime.datetime + :param link: The URL for the HTTP request. + :type link: ~azure.servicebus.management._generated.models.ResponseLink + :param content: The QueueDescription. + :type content: ~azure.servicebus.management._generated.models.RuleDescriptionEntryContent """ _attribute_map = { - 'href': {'key': 'href', 'type': 'str', 'xml': {'attr': True}}, - 'rel': {'key': 'rel', 'type': 'str', 'xml': {'attr': True}}, + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'published': {'key': 'published', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'link': {'key': 'link', 'type': 'ResponseLink'}, + 'content': {'key': 'content', 'type': 'RuleDescriptionEntryContent'}, } _xml_map = { - 'name': 'link', 'ns': 'http://www.w3.org/2005/Atom' + 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' } def __init__( self, *, - href: Optional[str] = None, - rel: Optional[str] = None, + id: Optional[str] = None, + title: Optional[object] = None, + published: Optional[datetime.datetime] = None, + updated: Optional[datetime.datetime] = None, + link: Optional["ResponseLink"] = None, + content: Optional["RuleDescriptionEntryContent"] = None, **kwargs ): - super(ResponseLink, self).__init__(**kwargs) - self.href = href - self.rel = rel + super(RuleDescriptionEntry, self).__init__(**kwargs) + self.id = id + self.title = title + self.published = published + self.updated = updated + self.link = link + self.content = content -class ResponseTitle(msrest.serialization.Model): - """The title of the response. +class RuleDescriptionEntryContent(msrest.serialization.Model): + """The QueueDescription. - :param type: Type of value. + :param type: Type of content in queue response. :type type: str - :param title: Contents of the title. - :type title: str + :param rule_description: + :type rule_description: ~azure.servicebus.management._generated.models.RuleDescription """ _attribute_map = { 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, - 'title': {'key': 'title', 'type': 'str'}, + 'rule_description': {'key': 'RuleDescription', 'type': 'RuleDescription'}, + } + _xml_map = { + 'ns': 'http://www.w3.org/2005/Atom' } def __init__( self, *, type: Optional[str] = None, - title: Optional[str] = None, + rule_description: Optional["RuleDescription"] = None, **kwargs ): - super(ResponseTitle, self).__init__(**kwargs) + super(RuleDescriptionEntryContent, self).__init__(**kwargs) self.type = type + self.rule_description = rule_description + + +class RuleDescriptionFeed(msrest.serialization.Model): + """Response from listing Service Bus queues. + + :param id: URL of the list queues query. + :type id: str + :param title: The entity type for the feed. + :type title: object + :param updated: Datetime of the query. + :type updated: ~datetime.datetime + :param link: Links to paginated response. + :type link: list[~azure.servicebus.management._generated.models.ResponseLink] + :param entry: Queue entries. + :type entry: list[~azure.servicebus.management._generated.models.RuleDescriptionEntry] + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'link': {'key': 'link', 'type': '[ResponseLink]'}, + 'entry': {'key': 'entry', 'type': '[RuleDescriptionEntry]'}, + } + _xml_map = { + 'name': 'feed', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + *, + id: Optional[str] = None, + title: Optional[object] = None, + updated: Optional[datetime.datetime] = None, + link: Optional[List["ResponseLink"]] = None, + entry: Optional[List["RuleDescriptionEntry"]] = None, + **kwargs + ): + super(RuleDescriptionFeed, self).__init__(**kwargs) + self.id = id self.title = title + self.updated = updated + self.link = link + self.entry = entry class ServiceBusManagementError(msrest.serialization.Model): @@ -695,90 +1193,592 @@ def __init__( self.detail = detail -class TopicDescription(msrest.serialization.Model): - """Description of a Service Bus topic resource. +class SqlFilter(RuleFilter): + """SqlFilter. - :param topic_name: Name of the topic. - :type topic_name: str - :param authorization_rules: Authorization rules for resource. - :type authorization_rules: - list[~azure.servicebus.management._generated.models.AuthorizationRule] - :param auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the topic is - automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: ~datetime.timedelta + :param type: Constant filled by server. + :type type: str + :param sql_expression: + :type sql_expression: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + 'sql_expression': {'key': 'SqlExpression', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + + def __init__( + self, + *, + sql_expression: Optional[str] = None, + **kwargs + ): + super(SqlFilter, self).__init__(**kwargs) + self.type: str = 'SqlFilter' + self.sql_expression = sql_expression + + +class SqlRuleAction(RuleAction): + """SqlRuleAction. + + :param type: Constant filled by server. + :type type: str + :param sql_expression: + :type sql_expression: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + 'sql_expression': {'key': 'SqlExpression', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + + def __init__( + self, + *, + sql_expression: Optional[str] = None, + **kwargs + ): + super(SqlRuleAction, self).__init__(**kwargs) + self.type: str = 'SqlRuleAction' + self.sql_expression = sql_expression + + +class SubscriptionDescription(msrest.serialization.Model): + """Description of a Service Bus queue resource. + + :param lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time + that the message is locked for other receivers. The maximum value for LockDuration is 5 + minutes; the default value is 1 minute. + :type lock_duration: ~datetime.timedelta + :param requires_session: A value that indicates whether the queue supports the concept of + sessions. + :type requires_session: bool :param default_message_time_to_live: ISO 8601 default message timespan to live value. This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself. :type default_message_time_to_live: ~datetime.timedelta - :param duplicate_detection_history_time_window: ISO 8601 timeSpan structure that defines the - duration of the duplicate detection history. The default value is 10 minutes. - :type duplicate_detection_history_time_window: ~datetime.timedelta + :param dead_lettering_on_message_expiration: A value that indicates whether this queue has dead + letter support when a message expires. + :type dead_lettering_on_message_expiration: bool + :param dead_lettering_on_filter_evaluation_exceptions: A value that indicates whether this + queue has dead letter support when a message expires. + :type dead_lettering_on_filter_evaluation_exceptions: bool + :param message_count: The number of messages in the queue. + :type message_count: int + :param max_delivery_count: The maximum delivery count. A message is automatically deadlettered + after this number of deliveries. Default value is 10. + :type max_delivery_count: int :param enable_batched_operations: Value that indicates whether server-side batched operations are enabled. :type enable_batched_operations: bool - :param enable_partitioning: A value that indicates whether the topic is to be partitioned - across multiple message brokers. - :type enable_partitioning: bool - :param max_size_in_megabytes: The maximum size of the topic in megabytes, which is the size of - memory allocated for the topic. - :type max_size_in_megabytes: long - :param requires_duplicate_detection: A value indicating if this topic requires duplicate - detection. - :type requires_duplicate_detection: bool :param status: Status of a Service Bus resource. Possible values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". :type status: str or ~azure.servicebus.management._generated.models.EntityStatus - :param support_ordering: A value that indicates whether the topic supports ordering. - :type support_ordering: bool - :param user_metadata: Metadata associated with the topic. - :type user_metadata: str + :param forward_to: .. raw:: html + + . + :type forward_to: str + :param created_at: The exact time the queue was created. + :type created_at: ~datetime.datetime + :param updated_at: The exact time a message was updated in the queue. + :type updated_at: ~datetime.datetime + :param accessed_at: Last time a message was sent, or the last time there was a receive request + to this queue. + :type accessed_at: ~datetime.datetime + :param message_count_details: Details about the message counts in queue. + :type message_count_details: ~azure.servicebus.management._generated.models.MessageCountDetails + :param auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the queue is + automatically deleted. The minimum duration is 5 minutes. + :type auto_delete_on_idle: ~datetime.timedelta + :param entity_availability_status: Availability status of the entity. Possible values include: + "Available", "Limited", "Renaming", "Restoring", "Unknown". + :type entity_availability_status: str or + ~azure.servicebus.management._generated.models.EntityAvailabilityStatus """ _attribute_map = { - 'topic_name': {'key': 'TopicName', 'type': 'str'}, - 'authorization_rules': {'key': 'AuthorizationRules', 'type': '[AuthorizationRule]', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'AuthorizationRule', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'auto_delete_on_idle': {'key': 'AutoDeleteOnIdle', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'lock_duration': {'key': 'LockDuration', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'requires_session': {'key': 'RequiresSession', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, 'default_message_time_to_live': {'key': 'DefaultMessageTimeToLive', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'duplicate_detection_history_time_window': {'key': 'DuplicateDetectionHistoryTimeWindow', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'dead_lettering_on_message_expiration': {'key': 'DeadLetteringOnMessageExpiration', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'DeadLetteringOnFilterEvaluationExceptions', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'message_count': {'key': 'MessageCount', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'max_delivery_count': {'key': 'MaxDeliveryCount', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, 'enable_batched_operations': {'key': 'EnableBatchedOperations', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_partitioning': {'key': 'EnablePartitioning', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_size_in_megabytes': {'key': 'MaxSizeInMegabytes', 'type': 'long'}, - 'requires_duplicate_detection': {'key': 'RequiresDuplicateDetection', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, 'status': {'key': 'Status', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'support_ordering': {'key': 'SupportOrdering', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'user_metadata': {'key': 'UserMetadata', 'type': 'str'}, + 'forward_to': {'key': 'ForwardTo', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'created_at': {'key': 'CreatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'updated_at': {'key': 'UpdatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'accessed_at': {'key': 'AccessedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'message_count_details': {'key': 'MessageCountDetails', 'type': 'MessageCountDetails'}, + 'auto_delete_on_idle': {'key': 'AutoDeleteOnIdle', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'entity_availability_status': {'key': 'EntityAvailabilityStatus', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, } _xml_map = { - 'name': 'TopicDescription', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' + 'name': 'SubscriptionDescription', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' } def __init__( self, *, - topic_name: Optional[str] = None, - authorization_rules: Optional[List["AuthorizationRule"]] = None, - auto_delete_on_idle: Optional[datetime.timedelta] = None, + lock_duration: Optional[datetime.timedelta] = None, + requires_session: Optional[bool] = None, default_message_time_to_live: Optional[datetime.timedelta] = None, - duplicate_detection_history_time_window: Optional[datetime.timedelta] = None, + dead_lettering_on_message_expiration: Optional[bool] = None, + dead_lettering_on_filter_evaluation_exceptions: Optional[bool] = None, + message_count: Optional[int] = None, + max_delivery_count: Optional[int] = None, enable_batched_operations: Optional[bool] = None, - enable_partitioning: Optional[bool] = None, - max_size_in_megabytes: Optional[int] = None, - requires_duplicate_detection: Optional[bool] = None, status: Optional[Union[str, "EntityStatus"]] = None, - support_ordering: Optional[bool] = None, - user_metadata: Optional[str] = None, + forward_to: Optional[str] = None, + created_at: Optional[datetime.datetime] = None, + updated_at: Optional[datetime.datetime] = None, + accessed_at: Optional[datetime.datetime] = None, + message_count_details: Optional["MessageCountDetails"] = None, + auto_delete_on_idle: Optional[datetime.timedelta] = None, + entity_availability_status: Optional[Union[str, "EntityAvailabilityStatus"]] = None, **kwargs ): - super(TopicDescription, self).__init__(**kwargs) - self.topic_name = topic_name - self.authorization_rules = authorization_rules - self.auto_delete_on_idle = auto_delete_on_idle + super(SubscriptionDescription, self).__init__(**kwargs) + self.lock_duration = lock_duration + self.requires_session = requires_session self.default_message_time_to_live = default_message_time_to_live - self.duplicate_detection_history_time_window = duplicate_detection_history_time_window + self.dead_lettering_on_message_expiration = dead_lettering_on_message_expiration + self.dead_lettering_on_filter_evaluation_exceptions = dead_lettering_on_filter_evaluation_exceptions + self.message_count = message_count + self.max_delivery_count = max_delivery_count self.enable_batched_operations = enable_batched_operations - self.enable_partitioning = enable_partitioning - self.max_size_in_megabytes = max_size_in_megabytes - self.requires_duplicate_detection = requires_duplicate_detection self.status = status - self.support_ordering = support_ordering - self.user_metadata = user_metadata + self.forward_to = forward_to + self.created_at = created_at + self.updated_at = updated_at + self.accessed_at = accessed_at + self.message_count_details = message_count_details + self.auto_delete_on_idle = auto_delete_on_idle + self.entity_availability_status = entity_availability_status + + +class SubscriptionDescriptionEntry(msrest.serialization.Model): + """Represents an entry in the feed when querying queues. + + :param id: The URL of the GET request. + :type id: str + :param title: The name of the subscription. + :type title: object + :param published: The timestamp for when this queue was published. + :type published: ~datetime.datetime + :param updated: The timestamp for when this queue was last updated. + :type updated: ~datetime.datetime + :param link: The URL for the HTTP request. + :type link: ~azure.servicebus.management._generated.models.ResponseLink + :param content: The QueueDescription. + :type content: + ~azure.servicebus.management._generated.models.SubscriptionDescriptionEntryContent + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'published': {'key': 'published', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'link': {'key': 'link', 'type': 'ResponseLink'}, + 'content': {'key': 'content', 'type': 'SubscriptionDescriptionEntryContent'}, + } + _xml_map = { + 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + *, + id: Optional[str] = None, + title: Optional[object] = None, + published: Optional[datetime.datetime] = None, + updated: Optional[datetime.datetime] = None, + link: Optional["ResponseLink"] = None, + content: Optional["SubscriptionDescriptionEntryContent"] = None, + **kwargs + ): + super(SubscriptionDescriptionEntry, self).__init__(**kwargs) + self.id = id + self.title = title + self.published = published + self.updated = updated + self.link = link + self.content = content + + +class SubscriptionDescriptionEntryContent(msrest.serialization.Model): + """The QueueDescription. + + :param type: Type of content in queue response. + :type type: str + :param subscription_description: Description of a Service Bus queue resource. + :type subscription_description: + ~azure.servicebus.management._generated.models.SubscriptionDescription + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, + 'subscription_description': {'key': 'SubscriptionDescription', 'type': 'SubscriptionDescription'}, + } + _xml_map = { + 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + *, + type: Optional[str] = None, + subscription_description: Optional["SubscriptionDescription"] = None, + **kwargs + ): + super(SubscriptionDescriptionEntryContent, self).__init__(**kwargs) + self.type = type + self.subscription_description = subscription_description + + +class SubscriptionDescriptionFeed(msrest.serialization.Model): + """Response from listing Service Bus queues. + + :param id: URL of the list queues query. + :type id: str + :param title: The entity type for the feed. + :type title: object + :param updated: Datetime of the query. + :type updated: ~datetime.datetime + :param link: Links to paginated response. + :type link: list[~azure.servicebus.management._generated.models.ResponseLink] + :param entry: Queue entries. + :type entry: list[~azure.servicebus.management._generated.models.SubscriptionDescriptionEntry] + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'link': {'key': 'link', 'type': '[ResponseLink]'}, + 'entry': {'key': 'entry', 'type': '[SubscriptionDescriptionEntry]'}, + } + _xml_map = { + 'name': 'feed', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + *, + id: Optional[str] = None, + title: Optional[object] = None, + updated: Optional[datetime.datetime] = None, + link: Optional[List["ResponseLink"]] = None, + entry: Optional[List["SubscriptionDescriptionEntry"]] = None, + **kwargs + ): + super(SubscriptionDescriptionFeed, self).__init__(**kwargs) + self.id = id + self.title = title + self.updated = updated + self.link = link + self.entry = entry + + +class TopicDescription(msrest.serialization.Model): + """Description of a Service Bus topic resource. + + :param default_message_time_to_live: ISO 8601 default message timespan to live value. This is + the duration after which the message expires, starting from when the message is sent to Service + Bus. This is the default value used when TimeToLive is not set on a message itself. + :type default_message_time_to_live: ~datetime.timedelta + :param max_size_in_megabytes: The maximum size of the topic in megabytes, which is the size of + memory allocated for the topic. + :type max_size_in_megabytes: long + :param requires_duplicate_detection: A value indicating if this topic requires duplicate + detection. + :type requires_duplicate_detection: bool + :param duplicate_detection_history_time_window: ISO 8601 timeSpan structure that defines the + duration of the duplicate detection history. The default value is 10 minutes. + :type duplicate_detection_history_time_window: ~datetime.timedelta + :param enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :type enable_batched_operations: bool + :param size_in_bytes: The size of the queue, in bytes. + :type size_in_bytes: int + :param filtering_messages_before_publishing: Filter messages before publishing. + :type filtering_messages_before_publishing: bool + :param is_anonymous_accessible: A value indicating if the resource can be accessed without + authorization. + :type is_anonymous_accessible: bool + :param authorization_rules: Authorization rules for resource. + :type authorization_rules: + list[~azure.servicebus.management._generated.models.AuthorizationRule] + :param status: Status of a Service Bus resource. Possible values include: "Active", "Creating", + "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". + :type status: str or ~azure.servicebus.management._generated.models.EntityStatus + :param created_at: The exact time the queue was created. + :type created_at: ~datetime.datetime + :param updated_at: The exact time a message was updated in the queue. + :type updated_at: ~datetime.datetime + :param accessed_at: Last time a message was sent, or the last time there was a receive request + to this queue. + :type accessed_at: ~datetime.datetime + :param support_ordering: A value that indicates whether the topic supports ordering. + :type support_ordering: bool + :param message_count_details: Details about the message counts in queue. + :type message_count_details: ~azure.servicebus.management._generated.models.MessageCountDetails + :param subscription_count: The number of subscriptions in the topic. + :type subscription_count: int + :param auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the topic is + automatically deleted. The minimum duration is 5 minutes. + :type auto_delete_on_idle: ~datetime.timedelta + :param enable_partitioning: A value that indicates whether the topic is to be partitioned + across multiple message brokers. + :type enable_partitioning: bool + :param entity_availability_status: Availability status of the entity. Possible values include: + "Available", "Limited", "Renaming", "Restoring", "Unknown". + :type entity_availability_status: str or + ~azure.servicebus.management._generated.models.EntityAvailabilityStatus + :param enable_subscription_partitioning: A value that indicates whether the topic's + subscription is to be partitioned. + :type enable_subscription_partitioning: bool + :param enable_express: A value that indicates whether Express Entities are enabled. An express + queue holds a message in memory temporarily before writing it to persistent storage. + :type enable_express: bool + :param user_metadata: Metadata associated with the topic. + :type user_metadata: str + """ + + _attribute_map = { + 'default_message_time_to_live': {'key': 'DefaultMessageTimeToLive', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'max_size_in_megabytes': {'key': 'MaxSizeInMegabytes', 'type': 'long', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'requires_duplicate_detection': {'key': 'RequiresDuplicateDetection', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'duplicate_detection_history_time_window': {'key': 'DuplicateDetectionHistoryTimeWindow', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'enable_batched_operations': {'key': 'EnableBatchedOperations', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'size_in_bytes': {'key': 'SizeInBytes', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'filtering_messages_before_publishing': {'key': 'FilteringMessagesBeforePublishing', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'is_anonymous_accessible': {'key': 'IsAnonymousAccessible', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'authorization_rules': {'key': 'AuthorizationRules', 'type': '[AuthorizationRule]', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'AuthorizationRule', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'status': {'key': 'Status', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'created_at': {'key': 'CreatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'updated_at': {'key': 'UpdatedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'accessed_at': {'key': 'AccessedAt', 'type': 'iso-8601', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'support_ordering': {'key': 'SupportOrdering', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'message_count_details': {'key': 'MessageCountDetails', 'type': 'MessageCountDetails'}, + 'subscription_count': {'key': 'SubscriptionCount', 'type': 'int', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'auto_delete_on_idle': {'key': 'AutoDeleteOnIdle', 'type': 'duration', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'enable_partitioning': {'key': 'EnablePartitioning', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'entity_availability_status': {'key': 'EntityAvailabilityStatus', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'enable_subscription_partitioning': {'key': 'EnableSubscriptionPartitioning', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'enable_express': {'key': 'EnableExpress', 'type': 'bool', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + 'user_metadata': {'key': 'UserMetadata', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + _xml_map = { + 'name': 'TopicDescription', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' + } + + def __init__( + self, + *, + default_message_time_to_live: Optional[datetime.timedelta] = None, + max_size_in_megabytes: Optional[int] = None, + requires_duplicate_detection: Optional[bool] = None, + duplicate_detection_history_time_window: Optional[datetime.timedelta] = None, + enable_batched_operations: Optional[bool] = None, + size_in_bytes: Optional[int] = None, + filtering_messages_before_publishing: Optional[bool] = None, + is_anonymous_accessible: Optional[bool] = None, + authorization_rules: Optional[List["AuthorizationRule"]] = None, + status: Optional[Union[str, "EntityStatus"]] = None, + created_at: Optional[datetime.datetime] = None, + updated_at: Optional[datetime.datetime] = None, + accessed_at: Optional[datetime.datetime] = None, + support_ordering: Optional[bool] = None, + message_count_details: Optional["MessageCountDetails"] = None, + subscription_count: Optional[int] = None, + auto_delete_on_idle: Optional[datetime.timedelta] = None, + enable_partitioning: Optional[bool] = None, + entity_availability_status: Optional[Union[str, "EntityAvailabilityStatus"]] = None, + enable_subscription_partitioning: Optional[bool] = None, + enable_express: Optional[bool] = None, + user_metadata: Optional[str] = None, + **kwargs + ): + super(TopicDescription, self).__init__(**kwargs) + self.default_message_time_to_live = default_message_time_to_live + self.max_size_in_megabytes = max_size_in_megabytes + self.requires_duplicate_detection = requires_duplicate_detection + self.duplicate_detection_history_time_window = duplicate_detection_history_time_window + self.enable_batched_operations = enable_batched_operations + self.size_in_bytes = size_in_bytes + self.filtering_messages_before_publishing = filtering_messages_before_publishing + self.is_anonymous_accessible = is_anonymous_accessible + self.authorization_rules = authorization_rules + self.status = status + self.created_at = created_at + self.updated_at = updated_at + self.accessed_at = accessed_at + self.support_ordering = support_ordering + self.message_count_details = message_count_details + self.subscription_count = subscription_count + self.auto_delete_on_idle = auto_delete_on_idle + self.enable_partitioning = enable_partitioning + self.entity_availability_status = entity_availability_status + self.enable_subscription_partitioning = enable_subscription_partitioning + self.enable_express = enable_express + self.user_metadata = user_metadata + + +class TopicDescriptionEntry(msrest.serialization.Model): + """Represents an entry in the feed when querying topics. + + :param base: Base URL for the query. + :type base: str + :param id: The URL of the GET request. + :type id: str + :param title: The name of the queue. + :type title: object + :param published: The timestamp for when this queue was published. + :type published: ~datetime.datetime + :param updated: The timestamp for when this queue was last updated. + :type updated: ~datetime.datetime + :param author: The author that created this resource. + :type author: ~azure.servicebus.management._generated.models.ResponseAuthor + :param link: The URL for the HTTP request. + :type link: ~azure.servicebus.management._generated.models.ResponseLink + :param content: The QueueDescription. + :type content: ~azure.servicebus.management._generated.models.TopicDescriptionEntryContent + """ + + _attribute_map = { + 'base': {'key': 'base', 'type': 'str', 'xml': {'name': 'base', 'attr': True, 'prefix': 'xml'}}, + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'published': {'key': 'published', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'author': {'key': 'author', 'type': 'ResponseAuthor'}, + 'link': {'key': 'link', 'type': 'ResponseLink'}, + 'content': {'key': 'content', 'type': 'TopicDescriptionEntryContent'}, + } + _xml_map = { + 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + *, + base: Optional[str] = None, + id: Optional[str] = None, + title: Optional[object] = None, + published: Optional[datetime.datetime] = None, + updated: Optional[datetime.datetime] = None, + author: Optional["ResponseAuthor"] = None, + link: Optional["ResponseLink"] = None, + content: Optional["TopicDescriptionEntryContent"] = None, + **kwargs + ): + super(TopicDescriptionEntry, self).__init__(**kwargs) + self.base = base + self.id = id + self.title = title + self.published = published + self.updated = updated + self.author = author + self.link = link + self.content = content + + +class TopicDescriptionEntryContent(msrest.serialization.Model): + """The QueueDescription. + + :param type: Type of content in queue response. + :type type: str + :param topic_description: Description of a Service Bus topic resource. + :type topic_description: ~azure.servicebus.management._generated.models.TopicDescription + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, + 'topic_description': {'key': 'TopicDescription', 'type': 'TopicDescription'}, + } + _xml_map = { + 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + *, + type: Optional[str] = None, + topic_description: Optional["TopicDescription"] = None, + **kwargs + ): + super(TopicDescriptionEntryContent, self).__init__(**kwargs) + self.type = type + self.topic_description = topic_description + + +class TopicDescriptionFeed(msrest.serialization.Model): + """Response from listing Service Bus queues. + + :param id: URL of the list queues query. + :type id: str + :param title: The entity type for the feed. + :type title: object + :param updated: Datetime of the query. + :type updated: ~datetime.datetime + :param link: Links to paginated response. + :type link: list[~azure.servicebus.management._generated.models.ResponseLink] + :param entry: Topic entries. + :type entry: list[~azure.servicebus.management._generated.models.TopicDescriptionEntry] + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'title': {'key': 'title', 'type': 'object'}, + 'updated': {'key': 'updated', 'type': 'iso-8601', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, + 'link': {'key': 'link', 'type': '[ResponseLink]'}, + 'entry': {'key': 'entry', 'type': '[TopicDescriptionEntry]'}, + } + _xml_map = { + 'name': 'feed', 'ns': 'http://www.w3.org/2005/Atom' + } + + def __init__( + self, + *, + id: Optional[str] = None, + title: Optional[object] = None, + updated: Optional[datetime.datetime] = None, + link: Optional[List["ResponseLink"]] = None, + entry: Optional[List["TopicDescriptionEntry"]] = None, + **kwargs + ): + super(TopicDescriptionFeed, self).__init__(**kwargs) + self.id = id + self.title = title + self.updated = updated + self.link = link + self.entry = entry + + +class TrueFilter(RuleFilter): + """TrueFilter. + + :param type: Constant filled by server. + :type type: str + :param sql_expression: + :type sql_expression: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + 'sql_expression': {'key': 'SqlExpression', 'type': 'str', 'xml': {'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + } + + def __init__( + self, + *, + sql_expression: Optional[str] = "1 = 1", + **kwargs + ): + super(TrueFilter, self).__init__(**kwargs) + self.type: str = 'TrueFilter' + self.sql_expression = sql_expression diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_service_bus_management_client_enums.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_service_bus_management_client_enums.py index 152d140b5976..faeb59e91e48 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_service_bus_management_client_enums.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_service_bus_management_client_enums.py @@ -17,7 +17,7 @@ class AccessRights(str, Enum): listen = "Listen" class EntityAvailabilityStatus(str, Enum): - """Availibility status of the entity + """Availability status of the entity """ available = "Available" @@ -39,3 +39,21 @@ class EntityStatus(str, Enum): restoring = "Restoring" send_disabled = "SendDisabled" unknown = "Unknown" + +class MessagingSku(str, Enum): + """The SKU for the messaging entity. + """ + + basic = "Basic" + standard = "Standard" + premium = "Premium" + +class NamespaceType(str, Enum): + """The type of entities the namespace can contain. + """ + + messaging = "Messaging" + notification_hub = "NotificationHub" + mixed = "Mixed" + event_hub = "EventHub" + relay = "Relay" diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/__init__.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/__init__.py index 032ef7a253fd..eae22edb0188 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/__init__.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/__init__.py @@ -6,10 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._queue_operations import QueueOperations +from ._entity_operations import EntityOperations from ._service_bus_management_client_operations import ServiceBusManagementClientOperationsMixin +from ._subscription_operations import SubscriptionOperations +from ._rule_operations import RuleOperations +from ._namespace_operations import NamespaceOperations __all__ = [ - 'QueueOperations', + 'EntityOperations', 'ServiceBusManagementClientOperationsMixin', + 'SubscriptionOperations', + 'RuleOperations', + 'NamespaceOperations', ] diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_queue_operations.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_entity_operations.py similarity index 87% rename from sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_queue_operations.py rename to sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_entity_operations.py index 400b34751f40..521e710dc2cf 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_queue_operations.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_entity_operations.py @@ -21,8 +21,8 @@ T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -class QueueOperations(object): - """QueueOperations operations. +class EntityOperations(object): + """EntityOperations operations. You should not instantiate this class directly. Instead, you should create a Client instance that instantiates it for you and attaches it as an attribute. @@ -45,18 +45,18 @@ def __init__(self, client, config, serializer, deserializer): def get( self, - queue_name, # type: str + entity_name, # type: str enrich=False, # type: Optional[bool] api_version="2017_04", # type: Optional[str] **kwargs # type: Any ): # type: (...) -> object - """Get the details about the Queue with the given queueName. + """Get the details about the Queue or Topic with the given entityName. - Get Queue. + Get Queue or Topic. - :param queue_name: The name of the queue relative to the Service Bus namespace. - :type queue_name: str + :param entity_name: The name of the queue or topic relative to the Service Bus namespace. + :type entity_name: str :param enrich: A query parameter that sets enrich to true or false. :type enrich: bool :param api_version: Api Version. @@ -74,7 +74,7 @@ def get( url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), + 'entityName': self._serialize.url("entity_name", entity_name, 'str', min_length=1), } url = self._client.format_url(url, **path_format_arguments) @@ -105,22 +105,22 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{queueName}'} # type: ignore + get.metadata = {'url': '/{entityName}'} # type: ignore def put( self, - queue_name, # type: str + entity_name, # type: str request_body, # type: object api_version="2017_04", # type: Optional[str] if_match=None, # type: Optional[str] **kwargs # type: Any ): # type: (...) -> object - """Create or update a queue at the provided queuePath. + """Create or update a queue or topic at the provided entityName. - :param queue_name: The name of the queue relative to the Service Bus namespace. - :type queue_name: str - :param request_body: Parameters required to make or edit a queue. + :param entity_name: The name of the queue or topic relative to the Service Bus namespace. + :type entity_name: str + :param request_body: Parameters required to make or edit a queue or topic. :type request_body: object :param api_version: Api Version. :type api_version: str @@ -137,13 +137,13 @@ def put( cls = kwargs.pop('cls', None) # type: ClsType[object] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/xml") + content_type = kwargs.pop("content_type", "application/atom+xml") # Construct URL url = self.put.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), + 'entityName': self._serialize.url("entity_name", entity_name, 'str', min_length=1), } url = self._client.format_url(url, **path_format_arguments) @@ -184,21 +184,21 @@ def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/{queueName}'} # type: ignore + put.metadata = {'url': '/{entityName}'} # type: ignore def delete( self, - queue_name, # type: str + entity_name, # type: str api_version="2017_04", # type: Optional[str] **kwargs # type: Any ): # type: (...) -> object - """Delete the Queue with the given queueName. + """Delete the Queue or Topic with the given entityName. - Delete Queue. + Delete Queue or Topic. - :param queue_name: The name of the queue relative to the Service Bus namespace. - :type queue_name: str + :param entity_name: The name of the queue or topic relative to the Service Bus namespace. + :type entity_name: str :param api_version: Api Version. :type api_version: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -214,7 +214,7 @@ def delete( url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), + 'entityName': self._serialize.url("entity_name", entity_name, 'str', min_length=1), } url = self._client.format_url(url, **path_format_arguments) @@ -243,4 +243,4 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{queueName}'} # type: ignore + delete.metadata = {'url': '/{entityName}'} # type: ignore diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_namespace_operations.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_namespace_operations.py new file mode 100644 index 000000000000..99947994be8c --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_namespace_operations.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class NamespaceOperations(object): + """NamespaceOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.servicebus.management._generated.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + api_version="2017_04", # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.NamespacePropertiesEntry" + """Get the details about the Service Bus namespace. + + Get Namespace Properties. + + :param api_version: Api Version. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NamespacePropertiesEntry, or the result of cls(response) + :rtype: ~azure.servicebus.management._generated.models.NamespacePropertiesEntry + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.NamespacePropertiesEntry"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('NamespacePropertiesEntry', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/$namespaceinfo'} # type: ignore diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_rule_operations.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_rule_operations.py new file mode 100644 index 000000000000..4bf126c0d286 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_rule_operations.py @@ -0,0 +1,270 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class RuleOperations(object): + """RuleOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.servicebus.management._generated.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + topic_name, # type: str + subscription_name, # type: str + rule_name, # type: str + enrich=False, # type: Optional[bool] + api_version="2017_04", # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> object + """Get the details about the rule of a subscription of a topic. + + Get Rule. + + :param topic_name: name of the topic. + :type topic_name: str + :param subscription_name: name of the subscription. + :type subscription_name: str + :param rule_name: name of the filter. + :type rule_name: str + :param enrich: A query parameter that sets enrich to true or false. + :type enrich: bool + :param api_version: Api Version. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', min_length=1), + 'ruleName': self._serialize.url("rule_name", rule_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if enrich is not None: + query_parameters['enrich'] = self._serialize.query("enrich", enrich, 'bool') + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + + def put( + self, + topic_name, # type: str + subscription_name, # type: str + rule_name, # type: str + request_body, # type: object + api_version="2017_04", # type: Optional[str] + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> object + """Create or update a rule. + + :param topic_name: name of the topic. + :type topic_name: str + :param subscription_name: name of the subscription. + :type subscription_name: str + :param rule_name: name of the filter. + :type rule_name: str + :param request_body: Parameters required to make or edit a rule. + :type request_body: object + :param api_version: Api Version. + :type api_version: str + :param if_match: Match condition for an entity to be updated. If specified and a matching + entity is not found, an error will be raised. To force an unconditional update, set to the + wildcard character (*). If not specified, an insert will be performed when no existing entity + is found to update and a replace will be performed if an existing entity is found. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/atom+xml") + + # Construct URL + url = self.put.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', min_length=1), + 'ruleName': self._serialize.url("rule_name", rule_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(request_body, 'object', is_xml=True) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + put.metadata = {'url': '/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + + def delete( + self, + topic_name, # type: str + subscription_name, # type: str + rule_name, # type: str + api_version="2017_04", # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> object + """Delete the rule with the given topicName, subscriptionName and ruleName. + + Delete Subscription. + + :param topic_name: name of the topic. + :type topic_name: str + :param subscription_name: name of the subscription. + :type subscription_name: str + :param rule_name: name of the filter. + :type rule_name: str + :param api_version: Api Version. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', min_length=1), + 'ruleName': self._serialize.url("rule_name", rule_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_service_bus_management_client_operations.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_service_bus_management_client_operations.py index 4695b3f7a5e7..367c39a964b4 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_service_bus_management_client_operations.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_service_bus_management_client_operations.py @@ -23,6 +23,148 @@ class ServiceBusManagementClientOperationsMixin(object): + def list_subscriptions( + self, + topic_name, # type: str + skip=0, # type: Optional[int] + top=100, # type: Optional[int] + api_version="2017_04", # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> object + """Get the details about the subscriptions of the given topic. + + Get subscriptions. + + :param topic_name: name of the topic. + :type topic_name: str + :param skip: + :type skip: int + :param top: + :type top: int + :param api_version: Api Version. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.list_subscriptions.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_subscriptions.metadata = {'url': '/{topicName}/subscriptions'} # type: ignore + + def list_rules( + self, + topic_name, # type: str + subscription_name, # type: str + skip=0, # type: Optional[int] + top=100, # type: Optional[int] + api_version="2017_04", # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> object + """Get the details about the rules of the given topic subscription. + + Get rules of a topic subscription. + + :param topic_name: name of the topic. + :type topic_name: str + :param subscription_name: name of the subscription. + :type subscription_name: str + :param skip: + :type skip: int + :param top: + :type top: int + :param api_version: Api Version. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.list_rules.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_rules.metadata = {'url': '/{topicName}/subscriptions/{subscriptionName}/rules'} # type: ignore + def list_entities( self, entity_type, # type: str diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_subscription_operations.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_subscription_operations.py new file mode 100644 index 000000000000..c4b4dfa9f4e2 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_subscription_operations.py @@ -0,0 +1,257 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionOperations(object): + """SubscriptionOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.servicebus.management._generated.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + topic_name, # type: str + subscription_name, # type: str + enrich=False, # type: Optional[bool] + api_version="2017_04", # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> object + """Get the details about the subscription of a topic. + + Get Subscription. + + :param topic_name: name of the topic. + :type topic_name: str + :param subscription_name: name of the subscription. + :type subscription_name: str + :param enrich: A query parameter that sets enrich to true or false. + :type enrich: bool + :param api_version: Api Version. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if enrich is not None: + query_parameters['enrich'] = self._serialize.query("enrich", enrich, 'bool') + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + + def put( + self, + topic_name, # type: str + subscription_name, # type: str + request_body, # type: object + api_version="2017_04", # type: Optional[str] + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> object + """Create or update a subscription. + + :param topic_name: name of the topic. + :type topic_name: str + :param subscription_name: name of the subscription. + :type subscription_name: str + :param request_body: Parameters required to make or edit a subscription. + :type request_body: object + :param api_version: Api Version. + :type api_version: str + :param if_match: Match condition for an entity to be updated. If specified and a matching + entity is not found, an error will be raised. To force an unconditional update, set to the + wildcard character (*). If not specified, an insert will be performed when no existing entity + is found to update and a replace will be performed if an existing entity is found. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/atom+xml") + + # Construct URL + url = self.put.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(request_body, 'object', is_xml=True) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + put.metadata = {'url': '/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + + def delete( + self, + topic_name, # type: str + subscription_name, # type: str + api_version="2017_04", # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> object + """Delete the subscription with the given topicName and subscriptionName. + + Delete Subscription. + + :param topic_name: name of the topic. + :type topic_name: str + :param subscription_name: name of the subscription. + :type subscription_name: str + :param api_version: Api Version. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: object, or the result of cls(response) + :rtype: object + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), + 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if api_version is not None: + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/xml' + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ServiceBusManagementError, response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/{topicName}/subscriptions/{subscriptionName}'} # type: ignore diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_handle_response_error.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_handle_response_error.py new file mode 100644 index 000000000000..809879e6c090 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_handle_response_error.py @@ -0,0 +1,18 @@ +from contextlib import contextmanager + +from azure.core.exceptions import HttpResponseError + +@contextmanager +def _handle_response_error(): + try: + yield + except HttpResponseError as response_error: + try: + new_response_error = HttpResponseError( + message=response_error.model.detail, + response=response_error.response, + model=response_error.model + ) + except AttributeError: + new_response_error = response_error + raise new_response_error \ No newline at end of file diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_management_client.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_management_client.py index 05b67dcc2c99..c7c17a5f9dc6 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_management_client.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_management_client.py @@ -2,14 +2,24 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- +import functools from copy import copy -from contextlib import contextmanager -from typing import TYPE_CHECKING, Dict, Any, Union, List, cast, Tuple -from xml.etree.ElementTree import ElementTree, Element +from typing import TYPE_CHECKING, Dict, Any, Union, cast +from xml.etree.ElementTree import ElementTree import six +from azure.core.paging import ItemPaged +from ._generated.models import QueueDescriptionFeed, TopicDescriptionEntry, \ + QueueDescriptionEntry, SubscriptionDescriptionFeed, SubscriptionDescriptionEntry, RuleDescriptionEntry, \ + RuleDescriptionFeed, NamespacePropertiesEntry, CreateTopicBody, CreateTopicBodyContent, \ + TopicDescriptionFeed, CreateSubscriptionBody, CreateSubscriptionBodyContent, CreateRuleBody, \ + CreateRuleBodyContent, CreateQueueBody, CreateQueueBodyContent, \ + QueueDescription as InternalQueueDescription, TopicDescription as InternalTopicDescription, \ + SubscriptionDescription as InternalSubscriptionDescription, RuleDescription as InternalRuleDescription +from ._utils import extract_data_template, get_next_template +from ._xml_workaround_policy import ServiceBusXMLWorkaroundPolicy from msrest.exceptions import ValidationError -from azure.core.exceptions import ResourceNotFoundError, HttpResponseError, raise_with_traceback +from azure.core.exceptions import raise_with_traceback, ResourceNotFoundError from azure.core.pipeline import Pipeline from azure.core.pipeline.policies import HttpLoggingPolicy, DistributedTracingPolicy, ContentDecodePolicy, \ RequestIdPolicy, BearerTokenCredentialPolicy @@ -20,45 +30,17 @@ from .._base_handler import ServiceBusSharedKeyCredential from ._shared_key_policy import ServiceBusSharedKeyCredentialPolicy from ._generated._configuration import ServiceBusManagementClientConfiguration -from ._generated.models import CreateQueueBody, CreateQueueBodyContent, \ - QueueDescription as InternalQueueDescription from ._generated._service_bus_management_client import ServiceBusManagementClient as ServiceBusManagementClientImpl -from ._model_workaround import QUEUE_DESCRIPTION_SERIALIZE_ATTRIBUTES, avoid_timedelta_overflow +from ._model_workaround import avoid_timedelta_overflow from . import _constants as constants -from ._models import QueueRuntimeInfo, QueueDescription - +from ._models import QueueRuntimeInfo, QueueDescription, TopicDescription, TopicRuntimeInfo, \ + SubscriptionDescription, SubscriptionRuntimeInfo, RuleDescription +from ._handle_response_error import _handle_response_error if TYPE_CHECKING: from azure.core.credentials import TokenCredential # pylint:disable=ungrouped-imports -@contextmanager -def _handle_response_error(): - try: - yield - except HttpResponseError as response_error: - try: - new_response_error = HttpResponseError( - message=response_error.model.detail, - response=response_error.response, - model=response_error.model - ) - except AttributeError: - new_response_error = response_error - raise new_response_error - - -def _convert_xml_to_object(queue_name, et): - # type: (str, Union[Element, ElementTree]) -> InternalQueueDescription - content_ele = cast(ElementTree, et).find(constants.CONTENT_TAG) - if not content_ele: - raise ResourceNotFoundError("Queue '{}' does not exist".format(queue_name)) - qc_ele = content_ele.find(constants.QUEUE_DESCRIPTION_TAG) - obj = InternalQueueDescription.deserialize(qc_ele) - - return obj - - class ServiceBusManagementClient: """Use this client to create, update, list, and delete resources of a ServiceBus namespace. @@ -76,6 +58,13 @@ def __init__(self, fully_qualified_namespace, credential, **kwargs): self._pipeline = self._build_pipeline() self._impl = ServiceBusManagementClientImpl(endpoint=fully_qualified_namespace, pipeline=self._pipeline) + def __enter__(self): + self._impl.__enter__() + return self + + def __exit__(self, *exc_details): + self._impl.__exit__(*exc_details) + def _build_pipeline(self, **kwargs): # pylint: disable=no-self-use transport = kwargs.get('transport') policies = kwargs.get('policies') @@ -89,6 +78,7 @@ def _build_pipeline(self, **kwargs): # pylint: disable=no-self-use self._config.user_agent_policy, self._config.proxy_policy, ContentDecodePolicy(**kwargs), + ServiceBusXMLWorkaroundPolicy(), self._config.redirect_policy, self._config.retry_policy, credential_policy, @@ -110,45 +100,38 @@ def from_connection_string(cls, conn_str, **kwargs): """ endpoint, shared_access_key_name, shared_access_key, _ = parse_conn_str(conn_str) if "//" in endpoint: - endpoint = endpoint[endpoint.index("//")+2:] + endpoint = endpoint[endpoint.index("//") + 2:] return cls(endpoint, ServiceBusSharedKeyCredential(shared_access_key_name, shared_access_key), **kwargs) - def _get_queue_object(self, queue_name, **kwargs): - # type: (str, Any) -> InternalQueueDescription - - if not queue_name: - raise ValueError("queue_name must be a non-empty str") + def _get_entity_element(self, entity_name, enrich=False, **kwargs): + # type: (str, bool, Any) -> ElementTree with _handle_response_error(): - et = cast( + element = cast( ElementTree, - self._impl.queue.get(queue_name, enrich=False, api_version=constants.API_VERSION, **kwargs) + self._impl.entity.get(entity_name, enrich=enrich, api_version=constants.API_VERSION, **kwargs) ) - return _convert_xml_to_object(queue_name, et) + return element - def _list_queues(self, **kwargs): - # type: (Any) -> List[Tuple[str, InternalQueueDescription]] + def _get_subscription_element(self, topic_name, subscription_name, enrich=False, **kwargs): + # type: (str, str, bool, Any) -> ElementTree - start_index = kwargs.pop("start_index", 0) - max_count = kwargs.pop("max_count", 100) with _handle_response_error(): - et = cast( + element = cast( ElementTree, - self._impl.list_entities( - entity_type=constants.ENTITY_TYPE_QUEUES, skip=start_index, top=max_count, - api_version=constants.API_VERSION, **kwargs - ) + self._impl.subscription.get(topic_name, subscription_name, enrich=enrich, api_version=constants.API_VERSION, **kwargs) ) - entries = et.findall(constants.ENTRY_TAG) - queues = [] - for entry in entries: - entity_name = entry.find(constants.TITLE_TAG).text # type: ignore - internal_object = _convert_xml_to_object( - entity_name, # type: ignore - cast(Element, entry) + return element + + def _get_rule_element(self, topic_name, subscription_name, rule_name, **kwargs): + # type: (str, str, str, Any) -> ElementTree + + with _handle_response_error(): + element = cast( + ElementTree, + self._impl.rule.get(topic_name, subscription_name, rule_name, enrich=False, api_version=constants.API_VERSION, **kwargs) ) - queues.append((entity_name, internal_object)) - return queues # type: ignore + return element def get_queue(self, queue_name, **kwargs): # type: (str, Any) -> QueueDescription @@ -157,10 +140,12 @@ def get_queue(self, queue_name, **kwargs): :param str queue_name: The name of the queue. :rtype: ~azure.servicebus.management.QueueDescription """ - queue_description = QueueDescription._from_internal_entity( # pylint:disable=protected-access - self._get_queue_object(queue_name, **kwargs) - ) - queue_description.queue_name = queue_name + entry_ele = self._get_entity_element(queue_name, **kwargs) + entry = QueueDescriptionEntry.deserialize(entry_ele) + if not entry.content: + raise ResourceNotFoundError("Queue '{}' does not exist".format(queue_name)) + queue_description = QueueDescription._from_internal_entity(entry.content.queue_description) + queue_description.name = queue_name return queue_description def get_queue_runtime_info(self, queue_name, **kwargs): @@ -170,10 +155,12 @@ def get_queue_runtime_info(self, queue_name, **kwargs): :param str queue_name: The name of the queue. :rtype: ~azure.servicebus.management.QueueRuntimeInfo """ - runtime_info = QueueRuntimeInfo._from_internal_entity( # pylint:disable=protected-access - self._get_queue_object(queue_name, **kwargs) - ) - runtime_info.queue_name = queue_name + entry_ele = self._get_entity_element(queue_name, **kwargs) + entry = QueueDescriptionEntry.deserialize(entry_ele) + if not entry.content: + raise ResourceNotFoundError("Queue {} does not exist".format(queue_name)) + runtime_info = QueueRuntimeInfo._from_internal_entity(entry.content.queue_description) + runtime_info.name = queue_name return runtime_info def create_queue(self, queue, **kwargs): @@ -183,11 +170,11 @@ def create_queue(self, queue, **kwargs): :param queue: The queue name or a `QueueDescription` instance. When it's a str, it will be the name of the created queue. Other properties of the created queue will have default values decided by the ServiceBus. Use a `QueueDescription` if you want to set queue properties other than the queue name. - :type queue: Union[str, QueueDescription] + :type queue: Union[str, ~azure.servicebus.management.QueueDescription] :rtype: ~azure.servicebus.management.QueueDescription """ try: - queue_name = queue.queue_name # type: ignore + queue_name = queue.name # type: ignore to_create = queue._to_internal_entity() # type: ignore # pylint:disable=protected-access except AttributeError: queue_name = queue # type: ignore @@ -201,9 +188,9 @@ def create_queue(self, queue, **kwargs): request_body = create_entity_body.serialize(is_xml=True) try: with _handle_response_error(): - et = cast( + entry_ele = cast( ElementTree, - self._impl.queue.put( + self._impl.entity.put( queue_name, # type: ignore request_body, api_version=constants.API_VERSION, **kwargs) ) @@ -212,35 +199,49 @@ def create_queue(self, queue, **kwargs): if isinstance(queue, (six.string_types, QueueDescription)): raise_with_traceback( ValueError, - message="queue must be a non-empty str or a QueueDescription with non-empty str queue_name") + message="queue must be a non-empty str or a QueueDescription with non-empty str name") raise_with_traceback( TypeError, - message="queue must be a non-empty str or a QueueDescription with non-empty str queue_name") + message="queue must be a non-empty str or a QueueDescription with non-empty str name") - result = QueueDescription._from_internal_entity( # pylint:disable=protected-access - _convert_xml_to_object(queue_name, et) - ) - result.queue_name = queue_name + entry = QueueDescriptionEntry.deserialize(entry_ele) + result = QueueDescription._from_internal_entity(entry.content.queue_description) + result.name = queue_name return result def update_queue(self, queue_description, **kwargs): - # type: (QueueDescription, Any) -> QueueDescription + # type: (QueueDescription, Any) -> None """Update a queue. :param queue_description: The properties of this `QueueDescription` will be applied to the queue in ServiceBus. Only a portion of properties can be updated. Refer to https://docs.microsoft.com/en-us/rest/api/servicebus/update-queue. :type queue_description: ~azure.servicebus.management.QueueDescription + :keyword timedelta default_message_time_to_live + :keyword timedelta lock_duration + :keyword bool dead_lettering_on_message_expiration + :keyword timedelta duplicate_detection_history_time_window + :keyword int max_delivery_count :rtype: ~azure.servicebus.management.QueueDescription """ + # TODO: validate whether a queue_description has enough information + if not isinstance(queue_description, QueueDescription): raise TypeError("queue_description must be of type QueueDescription") - to_update = copy(queue_description._to_internal_entity()) # pylint:disable=protected-access + internal_description = queue_description._to_internal_entity() + to_update = copy(internal_description) # pylint:disable=protected-access + + to_update.default_message_time_to_live = kwargs.get( + "default_message_time_to_live") or queue_description.default_message_time_to_live + to_update.lock_duration = kwargs.get("lock_duration") or queue_description.lock_duration + to_update.dead_lettering_on_message_expiration = kwargs.get( + "dead_lettering_on_message_expiration") or queue_description.dead_lettering_on_message_expiration + to_update.duplicate_detection_history_time_window = kwargs.get( + "duplicate_detection_history_time_window") or queue_description.duplicate_detection_history_time_window + to_update.max_delivery_count = kwargs.get("max_delivery_count") or queue_description.max_delivery_count - for attr in QUEUE_DESCRIPTION_SERIALIZE_ATTRIBUTES: - setattr(to_update, attr, getattr(queue_description, attr, None)) to_update.default_message_time_to_live = avoid_timedelta_overflow(to_update.default_message_time_to_live) to_update.auto_delete_on_idle = avoid_timedelta_overflow(to_update.auto_delete_on_idle) @@ -252,72 +253,618 @@ def update_queue(self, queue_description, **kwargs): request_body = create_entity_body.serialize(is_xml=True) with _handle_response_error(): try: - et = cast( - ElementTree, - self._impl.queue.put( - queue_description.queue_name, # type: ignore - request_body, - api_version=constants.API_VERSION, - if_match="*", - **kwargs - ) + self._impl.entity.put( + queue_description.name, # type: ignore + request_body, + api_version=constants.API_VERSION, + if_match="*", + **kwargs ) except ValidationError: # post-hoc try to give a somewhat-justifiable failure reason. raise_with_traceback( ValueError, message="queue_description must be a QueueDescription with valid fields, " - "including non-empty string queue name") - result = QueueDescription._from_internal_entity( # pylint:disable=protected-access - _convert_xml_to_object(queue_description.queue_name, et) - ) - result.queue_name = queue_description.queue_name - return result + "including non-empty string name") - def delete_queue(self, queue_name, **kwargs): - # type: (str, Any) -> None + def delete_queue(self, queue, **kwargs): + # type: (Union[str, QueueDescription], Any) -> None """Delete a queue. - :param str queue_name: The name of the queue. + :param Union[str, azure.servicebus.management.QueueDescription] queue: The name of the queue. :rtype: None """ - + try: + queue_name = queue.name + except AttributeError: + queue_name = queue if not queue_name: raise ValueError("queue_name must not be None or empty") with _handle_response_error(): - self._impl.queue.delete(queue_name, api_version=constants.API_VERSION, **kwargs) + self._impl.entity.delete(queue_name, api_version=constants.API_VERSION, **kwargs) def list_queues(self, **kwargs): - # type: (Any) -> List[QueueDescription] + # type: (Any) -> ItemPaged[QueueDescription] """List the queues of a ServiceBus namespace. :keyword int start_index: skip this number of queues. - :keyword int max_count: return at most this number of queues if there are more than this number in + :keyword int max_page_size: return at most this number of queues if there are more than this number in the ServiceBus namespace. - :rtype: List[~azure.servicebus.management.QueueDescription] - """ - result = [] # type: List[QueueDescription] - internal_queues = self._list_queues(**kwargs) - for queue_name, internal_queue in internal_queues: - qd = QueueDescription._from_internal_entity(internal_queue) # pylint:disable=protected-access - qd.queue_name = queue_name - result.append(qd) - return result + :rtype: ItemPaged[~azure.servicebus.management.QueueDescription] + """ + + def entry_to_qd(entry): + qd = QueueDescription._from_internal_entity(entry.content.queue_description) + qd.name = entry.title + return qd + + extract_data = functools.partial( + extract_data_template, QueueDescriptionFeed, entry_to_qd + ) + get_next = functools.partial( + get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_QUEUES), **kwargs + ) + return ItemPaged( + get_next, extract_data) def list_queues_runtime_info(self, **kwargs): - # type: (Any) -> List[QueueRuntimeInfo] + # type: (Any) -> ItemPaged[QueueRuntimeInfo] """List the runtime info of the queues in a ServiceBus namespace. :keyword int start_index: skip this number of queues. - :keyword int max_count: return at most this number of queues if there are more than this number in + :keyword int max_page_size: return at most this number of queues if there are more than this number in the ServiceBus namespace. - :rtype: List[~azure.servicebus.management.QueueRuntimeInfo] + :rtype: ItemPaged[~azure.servicebus.management.QueueRuntimeInfo] + """ + + def entry_to_qr(entry): + qd = QueueRuntimeInfo._from_internal_entity(entry.content.queue_description) + qd.name = entry.title + return qd + + extract_data = functools.partial( + extract_data_template, QueueDescriptionFeed, entry_to_qr + ) + get_next = functools.partial( + get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_QUEUES), **kwargs + ) + return ItemPaged( + get_next, extract_data) + + def get_topic(self, topic_name, **kwargs): + # type: (str, Any) -> TopicDescription + """Get a TopicDescription. + + :param str topic_name: The name of the queue. + :rtype: ~azure.servicebus.management.TopicDescription + """ + entry_ele = self._get_entity_element(topic_name, **kwargs) + entry = TopicDescriptionEntry.deserialize(entry_ele) + if not entry.content: + raise ResourceNotFoundError("Topic '{}' does not exist".format(topic_name)) + topic_description = TopicDescription._from_internal_entity(entry.content.topic_description) + topic_description.name = topic_name + return topic_description + + def get_topic_runtime_info(self, topic_name, **kwargs): + # type: (str, Any) -> TopicRuntimeInfo + """Get a TopicRuntimeInfo + + :param str topic_name: + :rtype: ~azure.servicebus.management.TopicRuntimeInfo + """ + entry_ele = self._get_entity_element(topic_name, **kwargs) + entry = TopicDescriptionEntry.deserialize(entry_ele) + if not entry.content: + raise ResourceNotFoundError("Topic {} does not exist".format(topic_name)) + topic_description = TopicRuntimeInfo._from_internal_entity(entry.content.topic_description) + topic_description.name = topic_name + return topic_description + + def create_topic(self, topic, **kwargs): + # type: (Union[str, TopicDescription], Any) -> TopicDescription + """ + + :param Union[str, ~azure.servicebus.management.TopicDescription] topic: + :rtype: ~azure.servicebus.management.TopicDescription + """ + try: + topic_name = topic.name # type: ignore + to_create = topic._to_internal_entity() # type: ignore # pylint:disable=protected-access + except AttributeError as e: + topic_name = topic # type: ignore + to_create = InternalTopicDescription() # Use an empty topic description. + + create_entity_body = CreateTopicBody( + content=CreateTopicBodyContent( + topic_description=to_create, # type: ignore + ) + ) + request_body = create_entity_body.serialize(is_xml=True) + try: + with _handle_response_error(): + entry_ele = cast( + ElementTree, + self._impl.entity.put( + topic_name, # type: ignore + request_body, api_version=constants.API_VERSION, **kwargs) + ) + except ValidationError as e: + # post-hoc try to give a somewhat-justifiable failure reason. + if isinstance(topic, (six.string_types, TopicDescription)): + raise_with_traceback( + ValueError, + message="topic must be a non-empty str or a QueueDescription with non-empty str name") + raise_with_traceback( + TypeError, + message="topic must be a non-empty str or a QueueDescription with non-empty str name") + + entry = TopicDescriptionEntry.deserialize(entry_ele) + result = TopicDescription._from_internal_entity(entry.content.topic_description) + result.name = topic_name + return result + + def update_topic(self, topic_description, **kwargs): + # type: (TopicDescription, Any) -> None + """ + + :param ~azure.servicebus.management.TopicDescription topic_description: + :keyword timedelta default_message_time_to_live: + :keyword timedelta duplicate_detection_history_time_window: + :rtype: None + """ + + # TODO: validate whether topic_description has enough information (refer to the create_topic response) + if not isinstance(topic_description, TopicDescription): + raise TypeError("topic_description must be of type TopicDescription") + + internal_description = topic_description._to_internal_entity() + to_update = copy(internal_description) # pylint:disable=protected-access + + to_update.default_message_time_to_live = kwargs.get("default_message_time_to_live") or topic_description.default_message_time_to_live + to_update.duplicate_detection_history_time_window = kwargs.get("duplicate_detection_history_time_window") or topic_description.duplicate_detection_history_time_window + + to_update.default_message_time_to_live = avoid_timedelta_overflow(to_update.default_message_time_to_live) + to_update.auto_delete_on_idle = avoid_timedelta_overflow(to_update.auto_delete_on_idle) + + create_entity_body = CreateTopicBody( + content=CreateTopicBodyContent( + topic_description=to_update, + ) + ) + request_body = create_entity_body.serialize(is_xml=True) + with _handle_response_error(): + try: + self._impl.entity.put( + topic_description.name, # type: ignore + request_body, + api_version=constants.API_VERSION, + if_match="*", + **kwargs + ) + except ValidationError: + # post-hoc try to give a somewhat-justifiable failure reason. + raise_with_traceback( + ValueError, + message="topic_description must be a TopicDescription with valid fields, " + "including non-empty string topic name") + + def delete_topic(self, topic, **kwargs): + # type: (Union[str, TopicDescription], Any) -> None + """ + + :param Union[str, TopicDescription] topic: + :rtype: None + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + self._impl.entity.delete(topic_name, api_version=constants.API_VERSION, **kwargs) + + def list_topics(self, **kwargs): + # type: (Any) -> ItemPaged[TopicDescription] + """ + :keyword int start_index: skip this number of queues. + :keyword int max_page_size: return at most this number of queues if there are more than this number in + the ServiceBus namespace. + :rtype: ItemPaged[~azure.servicebus.management.TopicDescription] + """ + def entry_to_topic(entry): + topic = TopicDescription._from_internal_entity(entry.content.topic_description) + topic.name = entry.title + return topic + + extract_data = functools.partial( + extract_data_template, TopicDescriptionFeed, entry_to_topic + ) + get_next = functools.partial( + get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_TOPICS), **kwargs + ) + return ItemPaged( + get_next, extract_data) + + def list_topics_runtime_info(self, **kwargs): + # type: (Any) -> ItemPaged[TopicRuntimeInfo] + """ + :keyword int start_index: skip this number of queues. + :keyword int max_page_size: return at most this number of queues if there are more than this number in + the ServiceBus namespace. + :rtype: ItemPaged[~azure.servicebus.management.TopicRuntimeInfo] + """ + def entry_to_topic(entry): + topic = TopicRuntimeInfo._from_internal_entity(entry.content.topic_description) + topic.name = entry.title + return topic + + extract_data = functools.partial( + extract_data_template, TopicDescriptionFeed, entry_to_topic + ) + get_next = functools.partial( + get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_TOPICS), **kwargs + ) + return ItemPaged( + get_next, extract_data) + + def get_subscription(self, topic, subscription_name, **kwargs): + # type: (Union[str, TopicDescription], str, Any) -> SubscriptionDescription + """ + + :param Union[str, TopicDescription] topic: + :param str subscription_name: + :rtype: ~azure.servicebus.management.SubscriptionDescription + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + entry_ele = self._get_subscription_element(topic_name, subscription_name, **kwargs) + entry = SubscriptionDescriptionEntry.deserialize(entry_ele) + if not entry.content: + raise ResourceNotFoundError( + "Subscription('Topic: {}, Subscription: {}') does not exist".format(subscription_name, topic_name)) + subscription = SubscriptionDescription._from_internal_entity(entry.content.subscription_description) + subscription.name = entry.title + return subscription + + def get_subscription_runtime_info(self, topic, subscription_name, **kwargs): + # type: (Union[str, TopicDescription], str, Any) -> SubscriptionRuntimeInfo + """ + + :param Union[str, TopicDescription] topic: + :param str subscription_name: + :rtype: ~azure.servicebus.management.SubscriptionRuntimeInfo + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + entry_ele = self._get_subscription_element(topic_name, subscription_name, **kwargs) + entry = SubscriptionDescriptionEntry.deserialize(entry_ele) + if not entry.content: + raise ResourceNotFoundError( + "Subscription('Topic: {}, Subscription: {}') does not exist".format(subscription_name, topic_name)) + subscription = SubscriptionRuntimeInfo._from_internal_entity(entry.content.subscription_description) + subscription.name = entry.title + return subscription + + def create_subscription(self, topic, subscription, **kwargs): + """ + + :param Union[str, TopicDescription] topic: + :param Union[str, ~azure.servicebus.management.SubscriptionDescription] subscription: + :rtype: ~azure.servicebus.management.SubscriptionDescription + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + try: + subscription_name = subscription.name # type: ignore + to_create = subscription._to_internal_entity() # type: ignore # pylint:disable=protected-access + except AttributeError: + subscription_name = subscription # type: ignore + to_create = InternalSubscriptionDescription() # Use an empty queue description. + + create_entity_body = CreateSubscriptionBody( + content=CreateSubscriptionBodyContent( + subscription_description=to_create, # type: ignore + ) + ) + request_body = create_entity_body.serialize(is_xml=True) + try: + with _handle_response_error(): + entry_ele = cast( + ElementTree, + self._impl.subscription.put( + topic_name, + subscription_name, # type: ignore + request_body, api_version=constants.API_VERSION, **kwargs) + ) + except ValidationError: + # post-hoc try to give a somewhat-justifiable failure reason. + # TODO: validate param topic + if isinstance(subscription, (six.string_types, SubscriptionDescription)): + raise_with_traceback( + ValueError, + message="subscription must be a non-empty str or a SubscriptionDescription with non-empty str name") + raise_with_traceback( + TypeError, + message="subscription must be a non-empty str or a SubscriptionDescription with non-empty str name") + + entry = SubscriptionDescriptionEntry.deserialize(entry_ele) + result = SubscriptionDescription._from_internal_entity(entry.content.subscription_description) + result.name = subscription_name + return result + + def update_subscription(self, topic, subscription_description, **kwargs): + """ + + :param Union[str, TopicDescription] topic: + :param ~azure.servicebus.management.SubscriptionDescription subscription: + :rtype: None """ + # TODO: validate param topic and whether subscription_description has enough properties. + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + if not isinstance(subscription_description, SubscriptionDescription): + raise TypeError("subscription_description must be of type SubscriptionDescription") - result = [] # type: List[QueueRuntimeInfo] - internal_queues = self._list_queues(**kwargs) - for queue_name, internal_queue in internal_queues: - runtime_info = QueueRuntimeInfo._from_internal_entity(internal_queue) # pylint:disable=protected-access - runtime_info.queue_name = queue_name - result.append(runtime_info) + internal_description = subscription_description._to_internal_entity() + to_update = copy(internal_description) # pylint:disable=protected-access + + to_update.default_message_time_to_live = avoid_timedelta_overflow(to_update.default_message_time_to_live) + to_update.auto_delete_on_idle = avoid_timedelta_overflow(to_update.auto_delete_on_idle) + + create_entity_body = CreateTopicBody( + content=CreateTopicBodyContent( + topic_description=to_update, + ) + ) + request_body = create_entity_body.serialize(is_xml=True) + with _handle_response_error(): + self._impl.subscription.put( + topic_name, + subscription_description.name, + request_body, + api_version=constants.API_VERSION, + if_match="*", + **kwargs + ) + + def delete_subscription(self, topic, subscription, **kwargs): + """ + :param Union[str, TopicDescription] topic: + :param Union[str, SubscriptionDescription] subscription: + :rtype: None + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + try: + subscription_name = subscription.name + except AttributeError: + subscription_name = subscription + self._impl.subscription.delete(topic_name, subscription_name, api_version=constants.API_VERSION, **kwargs) + + def list_subscriptions(self, topic, **kwargs): + """List the subscriptions of a ServiceBus Topic. + + :param Union[str, ~azure.servicebus.management.TopicDescription] topic: + :keyword int start_index: skip this number of queues. + :keyword int max_page_size: return at most this number of subscriptions if there are more than this number in + the ServiceBus Topic. + :rtype: ItemPaged[~azure.servicebus.management.SubscriptionDescription] + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + + def entry_to_subscription(entry): + subscription = SubscriptionDescription._from_internal_entity(entry.content.subscription_description) + subscription.name = entry.title + return subscription + + extract_data = functools.partial( + extract_data_template, SubscriptionDescriptionFeed, entry_to_subscription + ) + get_next = functools.partial( + get_next_template, functools.partial(self._impl.list_subscriptions, topic_name), **kwargs + ) + return ItemPaged( + get_next, extract_data) + + def list_subscriptions_runtime_info(self, topic, **kwargs): + """List the subscriptions of a ServiceBus Topic Runtime Information. + + :param Union[str, TopicDescription] topic: + :keyword int start_index: skip this number of queues. + :keyword int max_page_size: return at most this number of subscriptions if there are more than this number in + the ServiceBus Topic. + :rtype: ItemPaged[~azure.servicebus.management.SubscriptionRuntimeInfo] + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + + def entry_to_subscription(entry): + subscription = SubscriptionRuntimeInfo._from_internal_entity(entry.content.subscription_description) + subscription.name = entry.title + return subscription + + extract_data = functools.partial( + extract_data_template, SubscriptionDescriptionFeed, entry_to_subscription + ) + get_next = functools.partial( + get_next_template, functools.partial(self._impl.list_subscriptions, topic_name), **kwargs + ) + return ItemPaged( + get_next, extract_data) + + def get_rule(self, topic, subscription, rule_name, **kwargs): + """ + + :param Union[str, TopicDescription] topic: + :param Union[str, SubscriptionDescription] subscription: + :param str rule_name: + :rtype: ~azure.servicebus.management.RuleDescription + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + try: + subscription_name = subscription.name + except AttributeError: + subscription_name = subscription + entry_ele = self._get_rule_element(topic_name, subscription_name, rule_name, **kwargs) + entry = RuleDescriptionEntry.deserialize(entry_ele) + if not entry.content: + raise ResourceNotFoundError( + "Rule('Topic: {}, Subscription: {}, Rule {}') does not exist".format(subscription_name, topic_name, rule_name)) + rule_description = RuleDescription._from_internal_entity(entry.content.rule_description) + return rule_description + + def create_rule(self, topic, subscription, rule, **kwargs): + """ + :param Union[str, TopicDescription] topic: + :param Union[str, SubscriptionDescription] subscription: + :param Union[str, ~azure.servicebus.management.RuleDescription] rule: + :rtype: ~azure.servicebus.management.RuleDescription + """ + # TODO: validate param topic, subscription and rule. + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + try: + subscription_name = subscription.name + except AttributeError: + subscription_name = subscription + try: + rule_name = rule.name + to_create = rule._to_internal_entity() # type: ignore # pylint:disable=protected-access + except AttributeError: + rule_name = rule + to_create = InternalRuleDescription() # Use an empty queue description. + + create_entity_body = CreateRuleBody( + content=CreateRuleBodyContent( + rule_description=to_create, # type: ignore + ) + ) + request_body = create_entity_body.serialize(is_xml=True) + with _handle_response_error(): + entry_ele = self._impl.rule.put( + topic_name, + subscription_name, # type: ignore + rule_name, + request_body, api_version=constants.API_VERSION, **kwargs) + entry = RuleDescriptionEntry.deserialize(entry_ele) + result = entry.content.rule_description return result + + def update_rule(self, topic, subscription, rule_description, **kwargs): + """ + + :param Union[str, TopicDescription] topic: + :param Union[str, SubscriptionDescription] subscription: + :param ~azure.servicebus.management.RuleDescription rule_description: + :rtype: None + """ + # TODO: validate param topic, subscription and rule_description. + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + try: + subscription_name = subscription.name + except AttributeError: + subscription_name = subscription + + internal_description = rule_description._to_internal_entity() + to_update = copy(internal_description) # pylint:disable=protected-access + + create_entity_body = CreateRuleBody( + content=CreateRuleBodyContent( + rule_description=to_update, + ) + ) + request_body = create_entity_body.serialize(is_xml=True) + with _handle_response_error(): + self._impl.rule.put( + topic_name, + subscription_name, + rule_description.name, + request_body, + api_version=constants.API_VERSION, + if_match="*", + **kwargs + ) + + def delete_rule(self, topic, subscription, rule, **kwargs): + """ + + :param Union[str, TopicDescription] topic: + :param Union[str, SubscriptionDescription] subscription: + :param Union[str, RuleDescription] subscription: + :rtype: None + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + try: + subscription_name = subscription.name + except AttributeError: + subscription_name = subscription + try: + rule_name = rule.name + except AttributeError: + rule_name = rule + self._impl.rule.delete(topic_name, subscription_name, rule_name, api_version=constants.API_VERSION, **kwargs) + + def list_rules(self, topic, subscription, **kwargs): + """ + + :param Union[str, TopicDescription] topic: + :param Union[str, SubscriptionDescription] subscription: + :keyword int start_index: + :keyword int max_page_size: + :rtype: ItemPaged[~azure.servicebus.management.RuleDescription] + """ + try: + topic_name = topic.name + except AttributeError: + topic_name = topic + try: + subscription_name = subscription.name + except AttributeError: + subscription_name = subscription + + def entry_to_rule(entry): + rule = entry.content.rule_description + return RuleDescription._from_internal_entity(rule) + + extract_data = functools.partial( + extract_data_template, RuleDescriptionFeed, entry_to_rule + ) + get_next = functools.partial( + get_next_template, functools.partial(self._impl.list_rules, topic_name, subscription_name), **kwargs + ) + return ItemPaged( + get_next, extract_data) + + def get_namespace_properties(self, **kwargs): + """ + + :rtype: NamespaceProperties + """ + entry_el = self._impl.namespace.get(api_version=constants.API_VERSION, **kwargs) + namespace_entry = NamespacePropertiesEntry.deserialize(entry_el) + return namespace_entry.content.namespace_properties diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_model_workaround.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_model_workaround.py index 1f5f1729340f..6942206b09a2 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_model_workaround.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_model_workaround.py @@ -2,38 +2,47 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -from typing import Dict, Iterable, Any, Type, Optional +from typing import Dict, Iterable, Any, Optional from collections import OrderedDict from datetime import timedelta -from msrest.serialization import Model -from ._generated.models import QueueDescription +from azure.servicebus.management._generated.models import AuthorizationRule, CorrelationFilter, CreateQueueBodyContent, CreateRuleBodyContent, CreateSubscriptionBodyContent, CreateTopicBodyContent, FalseFilter, KeyValue, MessageCountDetails, NamespaceProperties, NamespacePropertiesEntry, NamespacePropertiesEntryContent, QueueDescription, QueueDescriptionEntry, QueueDescriptionEntryContent, QueueDescriptionFeed, ResponseLink, RuleDescription, RuleDescriptionEntry, RuleDescriptionEntryContent, RuleDescriptionFeed, ServiceBusManagementError, SqlFilter, SqlRuleAction, SubscriptionDescription, SubscriptionDescriptionEntry, SubscriptionDescriptionEntryContent, SubscriptionDescriptionFeed, TopicDescription, TopicDescriptionEntry, TopicDescriptionEntryContent, TopicDescriptionFeed, TrueFilter -QUEUE_DESCRIPTION_SERIALIZE_ATTRIBUTES = ( - 'lock_duration', - 'max_size_in_megabytes', - 'requires_duplicate_detection', - 'requires_session', - 'default_message_time_to_live', - 'dead_lettering_on_message_expiration', - 'duplicate_detection_history_time_window', - 'max_delivery_count', - 'enable_batched_operations', - 'size_in_bytes', - 'message_count', - 'is_anonymous_accessible', - 'authorization_rules', - 'status', - 'created_at', - 'updated_at', - 'accessed_at', - 'support_ordering', - 'message_count_details', - 'auto_delete_on_idle', - 'enable_partitioning', - 'entity_availability_status', - 'enable_express', -) +MODEL_CLASS_ATTRIBUTES = { + AuthorizationRule: ("type", "claim_type", "claim_value", "rights", "created_time", "modified_time", "key_name", "primary_key", "secondary_key"), + CorrelationFilter: ("type", "correlation_id", "message_id", "to", "reply_to", "label", "session_id", "reply_to_session_id", "content_type", "properties"), + CreateQueueBodyContent: ("type", "queue_description"), + CreateRuleBodyContent: ("type", "rule_description"), + CreateSubscriptionBodyContent: ("type", "subscription_description"), + CreateTopicBodyContent: ("type", "topic_description"), + FalseFilter: ("type", "sql_expression"), + KeyValue: ("key", "value"), + MessageCountDetails: ("active_message_count", "dead_letter_message_count", "scheduled_message_count", "transfer_dead_letter_message_count", "transfer_message_count"), + NamespaceProperties: ("alias", "created_time", "messaging_sku", "messaging_units", "modified_time", "name", "namespace_type"), + NamespacePropertiesEntry: ("id", "title", "updated", "author", "link", "content"), + NamespacePropertiesEntryContent: ("type", "namespace_properties"), + QueueDescription: ("lock_duration", "max_size_in_megabytes", "requires_duplicate_detection", "requires_session", "default_message_time_to_live", "dead_lettering_on_message_expiration", "duplicate_detection_history_time_window", "max_delivery_count", "enable_batched_operations", "size_in_bytes", "message_count", "is_anonymous_accessible", "authorization_rules", "status", "created_at", "updated_at", "accessed_at", "support_ordering", "message_count_details", "auto_delete_on_idle", "enable_partitioning", "entity_availability_status", "enable_express"), + QueueDescriptionEntry: ("base", "id", "title", "published", "updated", "author", "link", "content"), + QueueDescriptionEntryContent: ("type", "queue_description"), + QueueDescriptionFeed: ("id", "title", "updated", "link", "entry"), + ResponseLink: ("href", "rel"), + RuleDescription: ("filter", "action", "created_at", "name"), + RuleDescriptionEntry: ("id", "title", "published", "updated", "link", "content"), + RuleDescriptionEntryContent: ("type", "rule_description"), + RuleDescriptionFeed: ("id", "title", "updated", "link", "entry"), + ServiceBusManagementError: ("code", "detail"), + SqlFilter: ("type", "sql_expression"), + SqlRuleAction: ("type", "sql_expression"), + SubscriptionDescription: ("lock_duration", "requires_session", "default_message_time_to_live", "dead_lettering_on_message_expiration", "dead_lettering_on_filter_evaluation_exceptions", "message_count", "max_delivery_count", "enable_batched_operations", "status", "forward_to", "created_at", "updated_at", "accessed_at", "message_count_details", "auto_delete_on_idle", "entity_availability_status"), + SubscriptionDescriptionEntry: ("id", "title", "published", "updated", "link", "content"), + SubscriptionDescriptionEntryContent: ("type", "subscription_description"), + SubscriptionDescriptionFeed: ("id", "title", "updated", "link", "entry"), + TopicDescription: ("default_message_time_to_live", "max_size_in_megabytes", "requires_duplicate_detection", "duplicate_detection_history_time_window", "enable_batched_operations", "size_in_bytes", "filtering_messages_before_publishing", "is_anonymous_accessible", "authorization_rules", "status", "created_at", "updated_at", "accessed_at", "support_ordering", "message_count_details", "subscription_count", "auto_delete_on_idle", "enable_partitioning", "entity_availability_status", "enable_subscription_partitioning", "enable_express", "user_metadata"), + TopicDescriptionEntry: ("base", "id", "title", "published", "updated", "author", "link", "content"), + TopicDescriptionEntryContent: ("type", "topic_description"), + TopicDescriptionFeed: ("id", "title", "updated", "link", "entry"), + TrueFilter: ("type", "sql_expression"), +} def avoid_timedelta_overflow(td): @@ -50,7 +59,7 @@ def avoid_timedelta_overflow(td): return result -def adjust_dict_key_sequence(dct, keys): +def _adjust_dict_key_sequence(dct, keys): # type: (Dict[str, Any], Iterable[str]) -> Dict[str, Any] result = OrderedDict() @@ -60,17 +69,22 @@ def adjust_dict_key_sequence(dct, keys): return result -def adjust_attribute_map(class_): - # type: (Type[Model]) -> None - """update_queue will serialize QueueDescription to XML. The tags sequence is important to service. It doesn't - make sense but it is what it is. This workaround is to adjust the sequence of the items in Model - class _attribute_map so the serialized XML tags has the correct sequence. +def adjust_attribute_map(): + # type: () -> None + """update_xxx will serialize XXXDescription to XML. The tags sequence is important to service. + This workaround is to convert the _attribute_map of each model class + to use OrderedDict instead of dict so their serialized XML tags use the same sequence as + specified in MODEL_CLASS_ATTRIBUTES. """ # pylint:disable=protected-access - class_._attribute_map = adjust_dict_key_sequence( - class_._attribute_map, - QUEUE_DESCRIPTION_SERIALIZE_ATTRIBUTES - ) - - -adjust_attribute_map(QueueDescription) + for class_, attributes in MODEL_CLASS_ATTRIBUTES.items(): + class_._attribute_map = _adjust_dict_key_sequence( + class_._attribute_map, + attributes + ) + if "title" in class_._attribute_map: + class_._attribute_map["title"] = { + 'key': 'title', + 'type': 'str', + 'xml': {'ns': 'http://www.w3.org/2005/Atom'} + } diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_models.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_models.py index 8da5fe4f7176..8e7cca917dd5 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_models.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_models.py @@ -2,74 +2,94 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- +from collections import OrderedDict +from copy import deepcopy -from ._generated.models import QueueDescription as InternalQueueDescription +from azure.servicebus.management._generated.models import KeyValue + +from ._generated.models import QueueDescription as InternalQueueDescription, \ + TopicDescription as InternalTopicDescription, \ + SubscriptionDescription as InternalSubscriptionDescription, \ + RuleDescription as InternalRuleDescription, \ + SqlRuleAction as InternalSqlRuleAction, \ + EmptyRuleAction as InternalEmptyRuleAction, \ + CorrelationFilter as InternalCorrelationFilter, \ + SqlFilter as InternalSqlFilter, TrueFilter as InternalTrueFilter, FalseFilter as InternalFalseFilter + +from ._model_workaround import adjust_attribute_map + +adjust_attribute_map() class QueueDescription(object): # pylint:disable=too-many-instance-attributes """Description of a Service Bus queue resource. - :param queue_name: Name of the queue. - :type queue_name: str - :param authorization_rules: Authorization rules for resource. - :type authorization_rules: list[~azure.servicebus.management.AuthorizationRule] - :param auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the queue is - automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: ~datetime.timedelta - :param dead_lettering_on_message_expiration: A value that indicates whether this queue has dead - letter support when a message expires. - :type dead_lettering_on_message_expiration: bool - :param default_message_time_to_live: ISO 8601 default message timespan to live value. This is - the duration after which the message expires, starting from when the message is sent to Service - Bus. This is the default value used when TimeToLive is not set on a message itself. - :type default_message_time_to_live: ~datetime.timedelta - :param duplicate_detection_history_time_window: ISO 8601 timeSpan structure that defines the - duration of the duplicate detection history. The default value is 10 minutes. - :type duplicate_detection_history_time_window: ~datetime.timedelta - :param entity_availability_status: Availibility status of the entity. Possible values include: - "Available", "Limited", "Renaming", "Restoring", "Unknown". - :type entity_availability_status: str or - ~azure.servicebus.management.EntityAvailabilityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :param enable_express: A value that indicates whether Express Entities are enabled. An express - queue holds a message in memory temporarily before writing it to persistent storage. - :type enable_express: bool - :param enable_partitioning: A value that indicates whether the queue is to be partitioned - across multiple message brokers. - :type enable_partitioning: bool - :param is_anonymous_accessible: A value indicating if the resource can be accessed without - authorization. - :type is_anonymous_accessible: bool - :param lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time - that the message is locked for other receivers. The maximum value for LockDuration is 5 - minutes; the default value is 1 minute. - :type lock_duration: ~datetime.timedelta - :param max_delivery_count: The maximum delivery count. A message is automatically deadlettered - after this number of deliveries. Default value is 10. - :type max_delivery_count: int - :param max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size of - memory allocated for the queue. - :type max_size_in_megabytes: int - :param requires_duplicate_detection: A value indicating if this queue requires duplicate - detection. - :type requires_duplicate_detection: bool - :param requires_session: A value that indicates whether the queue supports the concept of - sessions. - :type requires_session: bool - :param status: Status of a Service Bus resource. Possible values include: "Active", "Creating", - "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". - :type status: str or ~azure.servicebus.management.EntityStatus - :param support_ordering: A value that indicates whether the queue supports ordering. - :type support_ordering: bool """ def __init__( self, **kwargs ): - self.queue_name = kwargs.get('queue_name', None) + """ + + :keyword name: Name of the queue. + :type name: str + :keyword authorization_rules: Authorization rules for resource. + :type authorization_rules: list[~azure.servicebus.management.AuthorizationRule] + :keyword auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the queue is + automatically deleted. The minimum duration is 5 minutes. + :type auto_delete_on_idle: ~datetime.timedelta + :keyword dead_lettering_on_message_expiration: A value that indicates whether this queue has dead + letter support when a message expires. + :type dead_lettering_on_message_expiration: bool + :keyword default_message_time_to_live: ISO 8601 default message timespan to live value. This is + the duration after which the message expires, starting from when the message is sent to Service + Bus. This is the default value used when TimeToLive is not set on a message itself. + :type default_message_time_to_live: ~datetime.timedelta + :keyword duplicate_detection_history_time_window: ISO 8601 timeSpan structure that defines the + duration of the duplicate detection history. The default value is 10 minutes. + :type duplicate_detection_history_time_window: ~datetime.timedelta + :keyword entity_availability_status: Availibility status of the entity. Possible values include: + "Available", "Limited", "Renaming", "Restoring", "Unknown". + :type entity_availability_status: str or + ~azure.servicebus.management.EntityAvailabilityStatus + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :type enable_batched_operations: bool + :keyword enable_express: A value that indicates whether Express Entities are enabled. An express + queue holds a message in memory temporarily before writing it to persistent storage. + :type enable_express: bool + :keyword enable_partitioning: A value that indicates whether the queue is to be partitioned + across multiple message brokers. + :type enable_partitioning: bool + :keyword is_anonymous_accessible: A value indicating if the resource can be accessed without + authorization. + :type is_anonymous_accessible: bool + :keyword lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time + that the message is locked for other receivers. The maximum value for LockDuration is 5 + minutes; the default value is 1 minute. + :type lock_duration: ~datetime.timedelta + :keyword max_delivery_count: The maximum delivery count. A message is automatically deadlettered + after this number of deliveries. Default value is 10. + :type max_delivery_count: int + :keyword max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size of + memory allocated for the queue. + :type max_size_in_megabytes: int + :keyword requires_duplicate_detection: A value indicating if this queue requires duplicate + detection. + :type requires_duplicate_detection: bool + :keyword requires_session: A value that indicates whether the queue supports the concept of + sessions. + :type requires_session: bool + :keyword status: Status of a Service Bus resource. Possible values include: "Active", "Creating", + "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". + :type status: str or ~azure.servicebus.management.EntityStatus + :keyword support_ordering: A value that indicates whether the queue supports ordering. + :type support_ordering: bool + + :rtype: None + """ + self.name = kwargs.get('name', None) self._internal_qd = None self.authorization_rules = kwargs.get('authorization_rules', None) @@ -89,13 +109,12 @@ def __init__( self.requires_session = kwargs.get('requires_session', None) self.status = kwargs.get('status', None) self.support_ordering = kwargs.get('support_ordering', None) - self.created_at = kwargs.get('created_at', None) @classmethod def _from_internal_entity(cls, internal_qd): # type: (InternalQueueDescription) -> QueueDescription qd = cls() - qd._internal_qd = internal_qd # pylint:disable=protected-access + qd._internal_qd = deepcopy(internal_qd) # pylint:disable=protected-access qd.authorization_rules = internal_qd.authorization_rules qd.auto_delete_on_idle = internal_qd.auto_delete_on_idle @@ -114,7 +133,6 @@ def _from_internal_entity(cls, internal_qd): qd.requires_session = internal_qd.requires_session qd.status = internal_qd.status qd.support_ordering = internal_qd.support_ordering - qd.created_at = internal_qd.created_at return qd @@ -140,7 +158,6 @@ def _to_internal_entity(self): self._internal_qd.requires_session = self.requires_session self._internal_qd.status = self.status self._internal_qd.support_ordering = self.support_ordering - self._internal_qd.created_at = self.created_at return self._internal_qd @@ -148,28 +165,32 @@ def _to_internal_entity(self): class QueueRuntimeInfo(object): """Service Bus queue metrics. - :param queue_name: Name of the queue. - :type queue_name: str - :param accessed_at: Last time a message was sent, or the last time there was a receive request - to this queue. - :type accessed_at: ~datetime.datetime - :param created_at: The exact time the queue was created. - :type created_at: ~datetime.datetime - :param updated_at: The exact time a message was updated in the queue. - :type updated_at: ~datetime.datetime - :param size_in_bytes: The size of the queue, in bytes. - :type size_in_bytes: int - :param message_count: The number of messages in the queue. - :type message_count: int - :param message_count_details: Details about the message counts in queue. - :type message_count_details: ~azure.servicebus.management.MessageCountDetails """ def __init__( self, **kwargs ): - self.queue_name = kwargs.get('queue_name', None) + """ + :keyword name: Name of the queue. + :type name: str + :keyword accessed_at: Last time a message was sent, or the last time there was a receive request + to this queue. + :type accessed_at: ~datetime.datetime + :keyword created_at: The exact time the queue was created. + :type created_at: ~datetime.datetime + :keyword updated_at: The exact time a message was updated in the queue. + :type updated_at: ~datetime.datetime + :keyword size_in_bytes: The size of the queue, in bytes. + :type size_in_bytes: int + :keyword message_count: The number of messages in the queue. + :type message_count: int + :keyword message_count_details: Details about the message counts in queue. + :type message_count_details: ~azure.servicebus.management.MessageCountDetails + + :rtype: None + """ + self.name = kwargs.get('name', None) self._internal_qr = None self.accessed_at = kwargs.get('accessed_at', None) @@ -183,7 +204,7 @@ def __init__( def _from_internal_entity(cls, internal_qr): # type: (InternalQueueDescription) -> QueueRuntimeInfo qr = cls() - qr._internal_qr = internal_qr # pylint:disable=protected-access + qr._internal_qr = deepcopy(internal_qr) # pylint:disable=protected-access qr.accessed_at = internal_qr.accessed_at qr.created_at = internal_qr.created_at @@ -193,3 +214,487 @@ def _from_internal_entity(cls, internal_qr): qr.message_count_details = internal_qr.message_count_details return qr + + +class TopicDescription(object): + """Description of a Service Bus topic resource. + + """ + def __init__( + self, + **kwargs + ): + """ + :keyword str name: + :keyword default_message_time_to_live: ISO 8601 default message timespan to live value. This is + the duration after which the message expires, starting from when the message is sent to Service + Bus. This is the default value used when TimeToLive is not set on a message itself. + :type default_message_time_to_live: ~datetime.timedelta + :keyword max_size_in_megabytes: The maximum size of the topic in megabytes, which is the size of + memory allocated for the topic. + :type max_size_in_megabytes: long + :keyword requires_duplicate_detection: A value indicating if this topic requires duplicate + detection. + :type requires_duplicate_detection: bool + :keyword duplicate_detection_history_time_window: ISO 8601 timeSpan structure that defines the + duration of the duplicate detection history. The default value is 10 minutes. + :type duplicate_detection_history_time_window: ~datetime.timedelta + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :type enable_batched_operations: bool + :keyword size_in_bytes: The size of the queue, in bytes. + :type size_in_bytes: int + :keyword is_anonymous_accessible: A value indicating if the resource can be accessed without + authorization. + :type is_anonymous_accessible: bool + :keyword authorization_rules: Authorization rules for resource. + :type authorization_rules: + list[~azure.servicebus.management._generated.models.AuthorizationRule] + :keyword status: Status of a Service Bus resource. Possible values include: "Active", "Creating", + "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". + :type status: str or ~azure.servicebus.management._generated.models.EntityStatus + :keyword support_ordering: A value that indicates whether the topic supports ordering. + :type support_ordering: bool + :keyword auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the topic is + automatically deleted. The minimum duration is 5 minutes. + :type auto_delete_on_idle: ~datetime.timedelta + :keyword enable_partitioning: A value that indicates whether the topic is to be partitioned + across multiple message brokers. + :type enable_partitioning: bool + :keyword entity_availability_status: Availability status of the entity. Possible values include: + "Available", "Limited", "Renaming", "Restoring", "Unknown". + :type entity_availability_status: str or + ~azure.servicebus.management._generated.models.EntityAvailabilityStatus + :keyword enable_subscription_partitioning: A value that indicates whether the topic's + subscription is to be partitioned. + :type enable_subscription_partitioning: bool + :keyword enable_express: A value that indicates whether Express Entities are enabled. An express + queue holds a message in memory temporarily before writing it to persistent storage. + :type enable_express: bool + :keyword user_metadata: Metadata associated with the topic. + :type user_metadata: str + + :rtype: None + """ + super(TopicDescription, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self._internal_td = None + + self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) + self.max_size_in_megabytes = kwargs.get('max_size_in_megabytes', None) + self.requires_duplicate_detection = kwargs.get('requires_duplicate_detection', None) + self.duplicate_detection_history_time_window = kwargs.get('duplicate_detection_history_time_window', None) + self.enable_batched_operations = kwargs.get('enable_batched_operations', None) + self.size_in_bytes = kwargs.get('size_in_bytes', None) + self.is_anonymous_accessible = kwargs.get('is_anonymous_accessible', None) + self.authorization_rules = kwargs.get('authorization_rules', None) + self.status = kwargs.get('status', None) + self.support_ordering = kwargs.get('support_ordering', None) + self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) + self.enable_partitioning = kwargs.get('enable_partitioning', None) + self.entity_availability_status = kwargs.get('entity_availability_status', None) + self.enable_subscription_partitioning = kwargs.get('enable_subscription_partitioning', None) + self.enable_express = kwargs.get('enable_express', None) + self.user_metadata = kwargs.get('user_metadata', None) + + @classmethod + def _from_internal_entity(cls, internal_td): + # type: (InternalTopicDescription) -> TopicDescription + qd = cls() + qd._internal_td = deepcopy(internal_td) + + qd.default_message_time_to_live = internal_td.default_message_time_to_live + qd.max_size_in_megabytes = internal_td.max_size_in_megabytes + qd.requires_duplicate_detection = internal_td.requires_duplicate_detection + qd.duplicate_detection_history_time_window = internal_td.duplicate_detection_history_time_window + qd.enable_batched_operations = internal_td.enable_batched_operations + qd.size_in_bytes = internal_td.size_in_bytes + qd.is_anonymous_accessible = internal_td.is_anonymous_accessible + qd.authorization_rules = internal_td.authorization_rules + qd.status = internal_td.status + qd.support_ordering = internal_td.support_ordering + qd.auto_delete_on_idle = internal_td.auto_delete_on_idle + qd.enable_partitioning = internal_td.enable_partitioning + qd.entity_availability_status = internal_td.entity_availability_status + qd.enable_subscription_partitioning = internal_td.enable_subscription_partitioning + qd.enable_express = internal_td.enable_express + qd.user_metadata = internal_td.user_metadata + + return qd + + def _to_internal_entity(self): + # type: () -> InternalTopicDescription + if not self._internal_td: + self._internal_td = InternalTopicDescription() + self._internal_td.default_message_time_to_live = self.default_message_time_to_live + self._internal_td.max_size_in_megabytes = self.max_size_in_megabytes + self._internal_td.requires_duplicate_detection = self.requires_duplicate_detection + self._internal_td.duplicate_detection_history_time_window = self.duplicate_detection_history_time_window + self._internal_td.enable_batched_operations = self.enable_batched_operations + self._internal_td.size_in_bytes = self.size_in_bytes + self._internal_td.is_anonymous_accessible = self.is_anonymous_accessible + self._internal_td.authorization_rules = self.authorization_rules + self._internal_td.status = self.status + self._internal_td.support_ordering = self.support_ordering + self._internal_td.auto_delete_on_idle = self.auto_delete_on_idle + self._internal_td.enable_partitioning = self.enable_partitioning + self._internal_td.entity_availability_status = self.entity_availability_status + self._internal_td.enable_subscription_partitioning = self.enable_subscription_partitioning + self._internal_td.enable_express = self.enable_express + self._internal_td.user_metadata = self.user_metadata + + return self._internal_td + + +class TopicRuntimeInfo(object): + """Description of a Service Bus topic resource. + + """ + def __init__( + self, + **kwargs + ): + """ + :keyword str name: + :keyword created_at: The exact time the queue was created. + :type created_at: ~datetime.datetime + :keyword updated_at: The exact time a message was updated in the queue. + :type updated_at: ~datetime.datetime + :keyword accessed_at: Last time a message was sent, or the last time there was a receive request + to this queue. + :type accessed_at: ~datetime.datetime + :keyword message_count_details: Details about the message counts in queue. + :type message_count_details: ~azure.servicebus.management._generated.models.MessageCountDetails + :keyword subscription_count: The number of subscriptions in the topic. + :type subscription_count: int + + :rtype: None + """ + super(TopicRuntimeInfo, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self._internal_td = None + self.created_at = kwargs.get('created_at', None) + self.updated_at = kwargs.get('updated_at', None) + self.accessed_at = kwargs.get('accessed_at', None) + self.message_count_details = kwargs.get('message_count_details', None) + self.subscription_count = kwargs.get('subscription_count', None) + + @classmethod + def _from_internal_entity(cls, internal_td): + # type: (InternalTopicDescription) -> TopicRuntimeInfo + qd = cls() + qd._internal_td = internal_td + + qd.created_at = internal_td.created_at + qd.updated_at = internal_td.updated_at + qd.accessed_at = internal_td.accessed_at + qd.message_count_details = internal_td.message_count_details + qd.subscription_count = internal_td.subscription_count + + return qd + + +class SubscriptionDescription(object): + """Description of a Service Bus queue resource. + + """ + def __init__(self, **kwargs): + """ + + :keyword str name: + :keyword lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time + that the message is locked for other receivers. The maximum value for LockDuration is 5 + minutes; the default value is 1 minute. + :type lock_duration: ~datetime.timedelta + :keyword requires_session: A value that indicates whether the queue supports the concept of + sessions. + :type requires_session: bool + :keyword default_message_time_to_live: ISO 8601 default message timespan to live value. This is + the duration after which the message expires, starting from when the message is sent to Service + Bus. This is the default value used when TimeToLive is not set on a message itself. + :type default_message_time_to_live: ~datetime.timedelta + :keyword dead_lettering_on_message_expiration: A value that indicates whether this queue has dead + letter support when a message expires. + :type dead_lettering_on_message_expiration: bool + :keyword dead_lettering_on_filter_evaluation_exceptions: A value that indicates whether this + queue has dead letter support when a message expires. + :type dead_lettering_on_filter_evaluation_exceptions: bool + :keyword message_count: The number of messages in the queue. + :type message_count: int + :keyword max_delivery_count: The maximum delivery count. A message is automatically deadlettered + after this number of deliveries. Default value is 10. + :type max_delivery_count: int + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :type enable_batched_operations: bool + :keyword status: Status of a Service Bus resource. Possible values include: "Active", "Creating", + "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". + :type status: str or ~azure.servicebus.management._generated.models.EntityStatus + :keyword forward_to: .. raw:: html + + . + :type forward_to: str + :keyword auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the queue is + automatically deleted. The minimum duration is 5 minutes. + :type auto_delete_on_idle: ~datetime.timedelta + :keyword entity_availability_status: Availability status of the entity. Possible values include: + "Available", "Limited", "Renaming", "Restoring", "Unknown". + :type entity_availability_status: str or + ~azure.servicebus.management._generated.models.EntityAvailabilityStatus + + :rtype: None + """ + super(SubscriptionDescription, self).__init__(**kwargs) + self.name = kwargs.get("name") + self._internal_sd = None + + self.lock_duration = kwargs.get('lock_duration', None) + self.requires_session = kwargs.get('requires_session', None) + self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) + self.dead_lettering_on_message_expiration = kwargs.get('dead_lettering_on_message_expiration', None) + self.dead_lettering_on_filter_evaluation_exceptions = kwargs.get( + 'dead_lettering_on_filter_evaluation_exceptions', None) + self.max_delivery_count = kwargs.get('max_delivery_count', None) + self.enable_batched_operations = kwargs.get('enable_batched_operations', None) + self.status = kwargs.get('status', None) + self.forward_to = kwargs.get('forward_to', None) + self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) + self.entity_availability_status = kwargs.get('entity_availability_status', None) + + @classmethod + def _from_internal_entity(cls, internal_subscription): + # type: (InternalSubscriptionDescription) -> SubscriptionDescription + subscription = cls() + subscription._internal_sd = internal_subscription + subscription.lock_duration = internal_subscription.lock_duration + subscription.requires_session = internal_subscription.requires_session + subscription.default_message_time_to_live = internal_subscription.default_message_time_to_live + subscription.dead_lettering_on_message_expiration = internal_subscription.dead_lettering_on_message_expiration + subscription.dead_lettering_on_filter_evaluation_exceptions = internal_subscription.dead_lettering_on_filter_evaluation_exceptions + subscription.max_delivery_count = internal_subscription.max_delivery_count + subscription.enable_batched_operations = internal_subscription.enable_batched_operations + subscription.status = internal_subscription.status + subscription.forward_to = internal_subscription.forward_to + subscription.auto_delete_on_idle = internal_subscription.auto_delete_on_idle + subscription.entity_availability_status = internal_subscription.entity_availability_status + + return subscription + + def _to_internal_entity(self): + # type: () -> InternalSubscriptionDescription + if not self._internal_sd: + self._internal_sd = InternalSubscriptionDescription() + self._internal_sd.lock_duration = self.lock_duration + self._internal_sd.requires_session = self.requires_session + self._internal_sd.default_message_time_to_live = self.default_message_time_to_live + self._internal_sd.dead_lettering_on_message_expiration = self.dead_lettering_on_message_expiration + self._internal_sd.dead_lettering_on_filter_evaluation_exceptions = self.dead_lettering_on_filter_evaluation_exceptions + self._internal_sd.max_delivery_count = self.max_delivery_count + self._internal_sd.enable_batched_operations = self.enable_batched_operations + self._internal_sd.status = self.status + self._internal_sd.forward_to = self.forward_to + self._internal_sd.auto_delete_on_idle = self.auto_delete_on_idle + self._internal_sd.entity_availability_status = self.entity_availability_status + + return self._internal_sd + + +class SubscriptionRuntimeInfo(object): + """Description of a Service Bus queue resource. + + """ + def __init__(self, **kwargs): + """ + + :keyword str name: + :keyword created_at: The exact time the queue was created. + :type created_at: ~datetime.datetime + :keyword updated_at: The exact time a message was updated in the queue. + :type updated_at: ~datetime.datetime + :keyword accessed_at: Last time a message was sent, or the last time there was a receive request + to this queue. + :type accessed_at: ~datetime.datetime + :keyword message_count_details: Details about the message counts in queue. + :type message_count_details: ~azure.servicebus.management._generated.models.MessageCountDetails + + :rtype: None + """ + super(SubscriptionRuntimeInfo, self).__init__(**kwargs) + self.name = kwargs.get("name") + + self.message_count = kwargs.get('message_count', None) + self.created_at = kwargs.get('created_at', None) + self.updated_at = kwargs.get('updated_at', None) + self.accessed_at = kwargs.get('accessed_at', None) + self.message_count_details = kwargs.get('message_count_details', None) + + @classmethod + def _from_internal_entity(cls, internal_subscription): + # type: (InternalSubscriptionDescription) -> SubscriptionRuntimeInfo + subscription = cls() + subscription._internal_sd = internal_subscription + subscription.message_count = internal_subscription.message_count + subscription.created_at = internal_subscription.created_at + subscription.updated_at = internal_subscription.updated_at + subscription.accessed_at = internal_subscription.accessed_at + subscription.message_count_details = internal_subscription.message_count_details + + return subscription + + +class RuleDescription(object): + """RuleDescription. + + """ + + def __init__(self, **kwargs): + """ + + :keyword filter: + :type filter: ~azure.servicebus.management._generated.models.RuleFilter + :keyword action: + :type action: ~azure.servicebus.management._generated.models.RuleAction + :keyword created_at: The exact time the queue was created. + :type created_at: ~datetime.datetime + :keyword name: + :type name: str + + :rtype: None + """ + super(RuleDescription, self).__init__(**kwargs) + self.filter = kwargs.get('filter', None) + self.action = kwargs.get('action', None) + self.created_at = kwargs.get('created_at', None) + self.name = kwargs.get('name', None) + + self._internal_rule = None + + @classmethod + def _from_internal_entity(cls, internal_rule): + # type: (InternalRuleDescription) -> RuleDescription + rule = cls() + rule._internal_rule = internal_rule + + rule.filter = RULE_CLASS_MAPPING[type(internal_rule.filter)]._from_internal_entity(internal_rule.filter) + rule.action = RULE_CLASS_MAPPING[type(internal_rule.action)]._from_internal_entity(internal_rule.action) \ + if internal_rule.action and type(internal_rule.action) != InternalEmptyRuleAction else None + rule.created_at = internal_rule.created_at + rule.name = internal_rule.name + + return rule + + def _to_internal_entity(self): + # type: () -> InternalRuleDescription + if not self._internal_rule: + self._internal_rule = InternalRuleDescription() + self._internal_rule.filter = self.filter._to_internal_entity() if self.filter else TRUE_FILTER + self._internal_rule.action = self.action._to_internal_entity() if self.action else EMPTY_RULE_ACTION + self._internal_rule.created_at = self.created_at + self._internal_rule.name = self.name + + return self._internal_rule + + +class CorrelationRuleFilter(object): + def __init__(self, **kwargs): + self.correlation_id = kwargs.get('correlation_id', None) + self.message_id = kwargs.get('message_id', None) + self.to = kwargs.get('to', None) + self.reply_to = kwargs.get('reply_to', None) + self.label = kwargs.get('label', None) + self.session_id = kwargs.get('session_id', None) + self.reply_to_session_id = kwargs.get('reply_to_session_id', None) + self.content_type = kwargs.get('content_type', None) + self.properties = kwargs.get('properties', None) + + @classmethod + def _from_internal_entity(cls, internal_correlation_filter): + # type: (InternalCorrelationFilter) -> CorrelationRuleFilter + correlation_filter = cls() + correlation_filter.correlation_id = internal_correlation_filter.correlation_id + correlation_filter.message_id = internal_correlation_filter.message_id + correlation_filter.to = internal_correlation_filter.to + correlation_filter.reply_to = internal_correlation_filter.reply_to + correlation_filter.label = internal_correlation_filter.label + correlation_filter.session_id = internal_correlation_filter.session_id + correlation_filter.reply_to_session_id = internal_correlation_filter.reply_to_session_id + correlation_filter.content_type = internal_correlation_filter.content_type + correlation_filter.properties = \ + OrderedDict((kv.key, kv.value) for kv in internal_correlation_filter.properties) \ + if internal_correlation_filter.properties else OrderedDict() + + return correlation_filter + + def _to_internal_entity(self): + internal_entity = InternalCorrelationFilter() + internal_entity.correlation_id = self.correlation_id + + internal_entity.message_id = self.message_id + internal_entity.to = self.to + internal_entity.reply_to = self.reply_to + internal_entity.label = self.label + internal_entity.session_id = self.session_id + internal_entity.reply_to_session_id = self.reply_to_session_id + internal_entity.content_type = self.content_type + internal_entity.properties = [KeyValue(key=key, value=value) for key, value in self.properties.items()] \ + if self.properties else None + + return internal_entity + + +class SqlRuleFilter(object): + def __init__(self, sql_expression=None): + self.sql_expression = sql_expression + + @classmethod + def _from_internal_entity(cls, internal_sql_rule_filter): + sql_rule_filter = cls() + sql_rule_filter.sql_expression = internal_sql_rule_filter.sql_expression + return sql_rule_filter + + def _to_internal_entity(self): + internal_entity = InternalSqlFilter(sql_expression=self.sql_expression) + return internal_entity + + +class TrueRuleFilter(SqlRuleFilter): + def __init__(self): + super(TrueRuleFilter, self).__init__("1=1") + + def _to_internal_entity(self): + internal_entity = InternalTrueFilter() + return internal_entity + + +class FalseRuleFilter(SqlRuleFilter): + def __init__(self): + super(FalseRuleFilter, self).__init__("1>1") + + def _to_internal_entity(self): + internal_entity = InternalFalseFilter() + return internal_entity + + +class SqlRuleAction(object): + def __init__(self, sql_expression=None): + self.sql_expression = sql_expression + + @classmethod + def _from_internal_entity(cls, internal_sql_rule_action): + sql_rule_filter = cls(internal_sql_rule_action.sql_expression) + return sql_rule_filter + + def _to_internal_entity(self): + return InternalSqlRuleAction(sql_expression=self.sql_expression) + + +RULE_CLASS_MAPPING = { + InternalSqlRuleAction: SqlRuleAction, + InternalEmptyRuleAction: None, + InternalCorrelationFilter: CorrelationRuleFilter, + InternalSqlFilter: SqlRuleFilter, + InternalTrueFilter: TrueRuleFilter, + InternalFalseFilter: FalseRuleFilter, +} +EMPTY_RULE_ACTION = InternalEmptyRuleAction() +TRUE_FILTER = TrueRuleFilter() diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_utils.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_utils.py new file mode 100644 index 000000000000..4f7607a3cd2f --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_utils.py @@ -0,0 +1,46 @@ +from typing import cast, Union +from xml.etree.ElementTree import ElementTree + + +try: + import urllib.parse as urlparse +except ImportError: + import urlparse # python 2.7 + +from azure.servicebus.management import _constants as constants +from ._handle_response_error import _handle_response_error + + +def extract_data_template(feed_class, convert, feed_element): + deserialized = feed_class.deserialize(feed_element) + list_of_qd = [convert(x) if convert else x for x in deserialized.entry] + next_link = None + if deserialized.link and len(deserialized.link) == 2: + next_link = deserialized.link[1].href + return next_link, iter(list_of_qd) + + +def get_next_template(list_func, *args, **kwargs): + if len(args) > 0: + next_link = args[0] + else: + next_link = kwargs.pop("next_link") + + start_index = kwargs.pop("start_index", 0) + max_page_size = kwargs.pop("max_page_size", 100) + api_version = constants.API_VERSION + if next_link: + queries = urlparse.parse_qs(urlparse.urlparse(next_link).query) + start_index = int(queries['$skip'][0]) + max_page_size = int(queries['$top'][0]) + api_version = queries['api-version'][0] + with _handle_response_error(): + feed_element = cast( + ElementTree, + list_func( + skip=start_index, top=max_page_size, + api_version=api_version, + **kwargs + ) + ) + return feed_element diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_xml_workaround_policy.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_xml_workaround_policy.py new file mode 100644 index 000000000000..90c5d87cbe06 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_xml_workaround_policy.py @@ -0,0 +1,37 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.core.pipeline import PipelineRequest +from azure.core.pipeline.policies import SansIOHTTPPolicy + + +class ServiceBusXMLWorkaroundPolicy(SansIOHTTPPolicy): + """A policy that mutates serialized XML to workaround ServiceBus requirement + + """ + def __init__(self): + # type: () -> None + super(ServiceBusXMLWorkaroundPolicy, self).__init__() + + def on_request(self, request): + # type: (PipelineRequest) -> None + """Mutate serialized (QueueDescription, TopicDescription, SubscriptionDescription, RuleDescription) + XML to use default namespace. + + :param request: The pipeline request object + :type request: ~azure.core.pipeline.PipelineRequest + """ + request_body = request.http_request.body + if request_body: + if b'' in request_body: + request_body = request_body.replace( + b'', + b'') + request.http_request.body = request_body + request.http_request.data = request_body + request.http_request.headers["Content-Length"] = str(len(request_body)) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/aio/_management_client_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/aio/_management_client_async.py deleted file mode 100644 index 177544455326..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/aio/_management_client_async.py +++ /dev/null @@ -1,287 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- -from copy import copy -from typing import TYPE_CHECKING, Dict, Any, Union, List, cast, Tuple -from xml.etree.ElementTree import ElementTree, Element - -from msrest.exceptions import ValidationError -from azure.core.exceptions import raise_with_traceback -from azure.core.pipeline import AsyncPipeline -from azure.core.pipeline.policies import HttpLoggingPolicy, DistributedTracingPolicy, ContentDecodePolicy, \ - RequestIdPolicy, AsyncBearerTokenCredentialPolicy -from azure.core.pipeline.transport import AioHttpTransport - -from ..._common.utils import parse_conn_str -from ..._common.constants import JWT_TOKEN_SCOPE -from ...aio._base_handler_async import ServiceBusSharedKeyCredential -from .._generated.aio._configuration_async import ServiceBusManagementClientConfiguration -from .._generated.models import CreateQueueBody, CreateQueueBodyContent, \ - QueueDescription as InternalQueueDescription -from .._generated.aio._service_bus_management_client_async import ServiceBusManagementClient \ - as ServiceBusManagementClientImpl -from .. import _constants as constants -from .._management_client import _convert_xml_to_object, _handle_response_error -from .._model_workaround import QUEUE_DESCRIPTION_SERIALIZE_ATTRIBUTES, avoid_timedelta_overflow -from ._shared_key_policy_async import AsyncServiceBusSharedKeyCredentialPolicy -from .._models import QueueRuntimeInfo, QueueDescription - - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential # pylint:disable=ungrouped-imports - - -class ServiceBusManagementClient: - """Use this client to create, update, list, and delete resources of a ServiceBus namespace. - - :param str fully_qualified_namespace: The fully qualified host name for the Service Bus namespace. - :param credential: To authenticate to manage the entities of the ServiceBus namespace. - :type credential: Union[TokenCredential, ServiceBusSharedKeyCredential] - """ - - def __init__(self, fully_qualified_namespace, credential, **kwargs): - # type: (str, Union[AsyncTokenCredential, ServiceBusSharedKeyCredential], Dict[str, Any]) -> None - - self.fully_qualified_namespace = fully_qualified_namespace - self._credential = credential - self._endpoint = "https://" + fully_qualified_namespace - self._config = ServiceBusManagementClientConfiguration(self._endpoint, **kwargs) - self._pipeline = self._build_pipeline() - self._impl = ServiceBusManagementClientImpl(endpoint=fully_qualified_namespace, pipeline=self._pipeline) - - def _build_pipeline(self, **kwargs): # pylint: disable=no-self-use - transport = kwargs.get('transport') - policies = kwargs.get('policies') - credential_policy = \ - AsyncServiceBusSharedKeyCredentialPolicy(self._endpoint, self._credential, "Authorization") \ - if isinstance(self._credential, ServiceBusSharedKeyCredential) \ - else AsyncBearerTokenCredentialPolicy(self._credential, JWT_TOKEN_SCOPE) - if policies is None: # [] is a valid policy list - policies = [ - RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - ContentDecodePolicy(**kwargs), - self._config.redirect_policy, - self._config.retry_policy, - credential_policy, - self._config.logging_policy, - DistributedTracingPolicy(**kwargs), - HttpLoggingPolicy(**kwargs), - ] - if not transport: - transport = AioHttpTransport(**kwargs) - return AsyncPipeline(transport, policies) - - @classmethod - def from_connection_string(cls, conn_str, **kwargs): - # type: (str, Any) -> ServiceBusManagementClient - """Create a client from connection string. - - :param str conn_str: The connection string of the Service Bus Namespace. - :rtype: ~azure.servicebus.management.aio.ServiceBusManagementClient - """ - endpoint, shared_access_key_name, shared_access_key, _ = parse_conn_str(conn_str) - if "//" in endpoint: - endpoint = endpoint[endpoint.index("//")+2:] - return cls(endpoint, ServiceBusSharedKeyCredential(shared_access_key_name, shared_access_key), **kwargs) - - async def _get_queue_object(self, queue_name, **kwargs): - # type: (str, Any) -> InternalQueueDescription - if not queue_name: - raise ValueError("queue_name must be a non-empty str") - with _handle_response_error(): - et = cast( - ElementTree, - await self._impl.queue.get(queue_name, enrich=False, api_version=constants.API_VERSION, **kwargs) - ) - return _convert_xml_to_object(queue_name, et) - - async def _list_queues(self, start_index, max_count, **kwargs): - # type: (int, int, Any) -> List[Tuple[str, InternalQueueDescription]] - with _handle_response_error(): - et = cast( - ElementTree, - await self._impl.list_entities( - entity_type=constants.ENTITY_TYPE_QUEUES, skip=start_index, top=max_count, - api_version=constants.API_VERSION, **kwargs - ) - ) - entries = et.findall(constants.ENTRY_TAG) - queues = [] - for entry in entries: - entity_name = entry.find(constants.TITLE_TAG).text # type: ignore - queue_description = _convert_xml_to_object( - entity_name, # type: ignore - cast(Element, entry), - ) - queues.append((entity_name, queue_description)) - return queues # type: ignore - - async def get_queue(self, queue_name: str, **kwargs) -> QueueDescription: - """Get a QueueDescription. - - :param str queue_name: The name of the queue. - :rtype: ~azure.servicebus.management.QueueDescription - """ - queue_description = QueueDescription._from_internal_entity( # pylint:disable=protected-access - await self._get_queue_object(queue_name, **kwargs) - ) - queue_description.queue_name = queue_name - return queue_description - - async def get_queue_runtime_info(self, queue_name: str, **kwargs) -> QueueRuntimeInfo: - """Get the runtime information of a queue. - - :param str queue_name: The name of the queue. - :rtype: ~azure.servicebus.management.QueueRuntimeInfo - """ - runtime_info = QueueRuntimeInfo._from_internal_entity( # pylint:disable=protected-access - await self._get_queue_object(queue_name, **kwargs) - ) - runtime_info.queue_name = queue_name - return runtime_info - - async def create_queue(self, queue: Union[str, QueueDescription], **kwargs) -> QueueDescription: - """Create a queue. - - :param queue: The queue name or a `QueueDescription` instance. When it's a str, it will be the name - of the created queue. Other properties of the created queue will have default values decided by the - ServiceBus. Use a `QueueDescription` if you want to set queue properties other than the queue name. - :type queue: Union[str, QueueDescription] - :rtype: ~azure.servicebus.management.QueueDescription - """ - try: - queue_name = queue.queue_name # type: ignore - to_create = queue._to_internal_entity() # type: ignore # pylint:disable=protected-access - except AttributeError: - queue_name = queue # type: ignore - to_create = InternalQueueDescription() # Use an empty queue description. - - create_entity_body = CreateQueueBody( - content=CreateQueueBodyContent( - queue_description=to_create, # type: ignore - ) - ) - request_body = create_entity_body.serialize(is_xml=True) - try: - with _handle_response_error(): - et = cast( - ElementTree, - await self._impl.queue.put( - queue_name, # type: ignore - request_body, api_version=constants.API_VERSION, **kwargs) - ) - except ValidationError: - # post-hoc try to give a somewhat-justifiable failure reason. - if isinstance(queue, (str, QueueDescription)): - raise_with_traceback( - ValueError, - message="queue must be a non-empty str or a QueueDescription with non-empty str queue_name") - raise_with_traceback( - TypeError, - message="queue must be a non-empty str or a QueueDescription with non-empty str queue_name") - - result = QueueDescription._from_internal_entity( # pylint:disable=protected-access - _convert_xml_to_object(queue_name, et) - ) - result.queue_name = queue_name - return result - - async def update_queue(self, queue_description: QueueDescription, **kwargs) -> QueueDescription: - """Update a queue. - - :param queue_description: The properties of this `QueueDescription` will be applied to the queue in - ServiceBus. Only a portion of properties can be updated. - Refer to https://docs.microsoft.com/en-us/rest/api/servicebus/update-queue. - :type queue_description: ~azure.servicebus.management.QueueDescription - :rtype: ~azure.servicebus.management.QueueDescription - """ - - if not isinstance(queue_description, QueueDescription): - raise TypeError("queue_description must be of type QueueDescription") - - to_update = copy(queue_description._to_internal_entity()) # pylint:disable=protected-access - - for attr in QUEUE_DESCRIPTION_SERIALIZE_ATTRIBUTES: - setattr(to_update, attr, getattr(queue_description, attr, None)) - to_update.default_message_time_to_live = avoid_timedelta_overflow(to_update.default_message_time_to_live) - to_update.auto_delete_on_idle = avoid_timedelta_overflow(to_update.auto_delete_on_idle) - - create_entity_body = CreateQueueBody( - content=CreateQueueBodyContent( - queue_description=to_update, - ) - ) - request_body = create_entity_body.serialize(is_xml=True) - with _handle_response_error(): - try: - et = cast( - ElementTree, - await self._impl.queue.put( - queue_description.queue_name, # type: ignore - request_body, - api_version=constants.API_VERSION, - if_match="*", - **kwargs - ) - ) - except ValidationError: - # post-hoc try to give a somewhat-justifiable failure reason. - raise_with_traceback( - ValueError, - message="queue_description must be a QueueDescription with valid fields, " - "including non-empty string queue name") - - result = QueueDescription._from_internal_entity( # pylint:disable=protected-access - _convert_xml_to_object(queue_description.queue_name, et) - ) - result.queue_name = queue_description.queue_name - return result - - async def delete_queue(self, queue_name: str, **kwargs) -> None: - """Delete a queue. - - :param str queue_name: The name of the queue. - :rtype: None - """ - - if not queue_name: - raise ValueError("queue_name must not be None or empty") - with _handle_response_error(): - await self._impl.queue.delete(queue_name, api_version=constants.API_VERSION, **kwargs) - - async def list_queues(self, *, start_index: int = 0, max_count: int = 100, **kwargs) -> List[QueueDescription]: - """List the queues of a ServiceBus namespace. - - :keyword int start_index: skip this number of queues. - :keyword int max_count: return at most this number of queues if there are more than this number in - the ServiceBus namespace. - :rtype: List[~azure.servicebus.management.QueueDescription] - """ - result = [] # type: List[QueueDescription] - internal_queues = await self._list_queues(start_index, max_count, **kwargs) - for queue_name, internal_queue in internal_queues: - qd = QueueDescription._from_internal_entity(internal_queue) # pylint:disable=protected-access - qd.queue_name = queue_name - result.append(qd) - return result - - async def list_queues_runtime_info( - self, *, start_index: int = 0, max_count: int = 100, **kwargs) -> List[QueueRuntimeInfo]: - """List the runtime info of the queues in a ServiceBus namespace. - - :keyword int start_index: skip this number of queues. - :keyword int max_count: return at most this number of queues if there are more than this number in - the ServiceBus namespace. - :rtype: List[~azure.servicebus.management.QueueRuntimeInfo] - """ - result = [] # type: List[QueueRuntimeInfo] - internal_queues = await self._list_queues(start_index, max_count, **kwargs) - for queue_name, internal_queue in internal_queues: - runtime_info = QueueRuntimeInfo._from_internal_entity(internal_queue) # pylint:disable=protected-access - runtime_info.queue_name = queue_name - result.append(runtime_info) - return result diff --git a/sdk/servicebus/azure-servicebus/swagger/README.md b/sdk/servicebus/azure-servicebus/swagger/README.md index af12a5c4a831..209922fd59d2 100644 --- a/sdk/servicebus/azure-servicebus/swagger/README.md +++ b/sdk/servicebus/azure-servicebus/swagger/README.md @@ -17,7 +17,7 @@ autorest --use=@autorest/python@5.0.0-preview.6 ``` ### Settings ``` yaml -input-file: servicebus-swagger.json +input-file: C:/Work/azure-rest-api-specs-pr/specification/servicebus/data-plane/servicebus-swagger.json output-folder: ../azure/servicebus/management/_generated namespace: azure.servicebus.management._generated no-namespace-folders: true @@ -27,4 +27,4 @@ vanilla: true clear-output-folder: true python: true package-version: "2017-04" -``` \ No newline at end of file +``` diff --git a/sdk/servicebus/azure-servicebus/swagger/generate_attributes_sequence_tuple.py b/sdk/servicebus/azure-servicebus/swagger/generate_attributes_sequence_tuple.py new file mode 100644 index 000000000000..a5a385366bd6 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/swagger/generate_attributes_sequence_tuple.py @@ -0,0 +1,33 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +# This is a tool, not a part of the SDK code. Run it with Python 3.6+. +# +# It iterates the _attribute_map of model classes and print the attributes of each class into a tuple. +# `dict` in Python 3.6+ guarantees order when iterating over the dict so the attributes tuple +# has the correct order of model class attributes. +# Copy the output to file azure.servicebus.management._model_workaround.py, which will convert +# _attribute_map of each model class from dict to OrderedDict. + +import inspect +from msrest.serialization import Model +from azure.servicebus.management._generated.models import _models_py3 + + +if __name__ == '__main__': + members = inspect.getmembers(_models_py3, inspect.isclass) + class_names = [] + model_class_attributes_string = "MODEL_CLASS_ATTRIBUTES = {\n" + for class_name, class_ in members: + if issubclass(class_, Model) and len(class_._attribute_map) > 1: + attributes = ", ".join('"'+x + '"' for x in class_._attribute_map.keys()) + attributes = " {}: ({})".format(class_name, attributes) + model_class_attributes_string += attributes+",\n" + class_names.append(class_name) + model_class_attributes_string += "}\n" + print("from azure.servicebus.management._generated.models import", ", ".join(class_names)) + print("\n") + print(model_class_attributes_string) diff --git a/sdk/servicebus/azure-servicebus/swagger/servicebus-swagger.json b/sdk/servicebus/azure-servicebus/swagger/servicebus-swagger.json deleted file mode 100644 index 981615cac716..000000000000 --- a/sdk/servicebus/azure-servicebus/swagger/servicebus-swagger.json +++ /dev/null @@ -1,960 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "2017_04", - "title": "ServiceBusManagementClient", - "description": "Azure Service Bus client for managing Queues, Topics, and Subscriptions.", - "x-ms-code-generation-settings": { - "internalConstructors": true, - "name": "ServiceBusManagementClient" - } - }, - "x-ms-parameterized-host": { - "hostTemplate": "{endpoint}", - "parameters": [ - { - "$ref": "#/parameters/Endpoint" - } - ] - }, - "schemes": [ - "https" - ], - "produces": [ - "application/xml" - ], - "consumes": [ - "application/xml" - ], - "tags": [ - { - "name": "Queue Operations" - }, - { - "name": "Topic Operations" - }, - { - "name": "Subscription Operations" - } - ], - "parameters": { - "ApiVersion": { - "name": "api-version", - "in": "query", - "type": "string", - "default": "2017-04", - "description": "Specifies the version of the REST protocol used for processing the request. This is required when using shared key authorization.", - "minLength": 1, - "x-ms-parameter-location": "client" - }, - "Endpoint": { - "in": "path", - "name": "endpoint", - "description": "The Service Bus fully qualified domain name.", - "required": true, - "type": "string", - "x-ms-skip-url-encoding": true, - "x-ms-parameter-location": "client" - }, - "Enrich": { - "name": "enrich", - "in": "query", - "description": "A query parameter that sets enrich to true or false.", - "type": "boolean", - "default": false, - "x-ms-parameter-location": "method" - } - }, - "definitions": { - "AccessRights": { - "description": "Access rights of the entity", - "type": "string", - "xml": { - "name": "AccessRights", - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "enum": [ - "Manage", - "Send", - "Listen" - ] - }, - "AuthorizationRule": { - "description": "Authorization rule of an entity", - "type": "object", - "xml": { - "name": "AuthorizationRule", - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "properties": { - "type": { - "type": "string", - "xml": { - "attribute": true, - "prefix": "i", - "namespace": "http://www.w3.org/2001/XMLSchema-instance" - } - }, - "ClaimType": { - "type": "string", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "ClaimValue": { - "type": "string", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "Rights": { - "description": "Access rights of the entity. Values are 'Send', 'Listen', or 'Manage'", - "type": "array", - "xml": { - "wrapped": true, - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "items": { - "type": "string", - "xml": { - "name": "AccessRights", - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - } - }, - "CreatedTime": { - "description": "The date and time when the authorization rule was created.", - "type": "string", - "format": "date-time", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "ModifiedTime": { - "description": "The date and time when the authorization rule was modified.", - "type": "string", - "format": "date-time", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "KeyName": { - "description": "The authorization rule key name", - "type": "string", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "PrimaryKey": { - "description": "The primary key of the authorization rule", - "type": "string", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "SecondaryKey": { - "description": "The primary key of the authorization rule", - "type": "string", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - } - } - }, - "CreateQueueBody": { - "description": "The request body for creating a queue.", - "type": "object", - "xml": { - "name": "entry", - "namespace": "http://www.w3.org/2005/Atom" - }, - "properties": { - "content": { - "description": "QueueDescription for the new queue.", - "type": "object", - "xml": { - "namespace": "http://www.w3.org/2005/Atom" - }, - "properties": { - "type": { - "description": "MIME type of content.", - "type": "string", - "default": "application/xml", - "xml": { - "attribute": true - } - }, - "QueueDescription": { - "description": "Properties of the new queue.", - "$ref": "#/definitions/QueueDescription" - } - } - } - } - }, - "CreateTopicBody": { - "description": "The request body for creating a topic.", - "type": "object", - "xml": { - "name": "entry", - "namespace": "http://www.w3.org/2005/Atom" - }, - "properties": { - "content": { - "description": "TopicDescription for the new topic.", - "type": "object", - "xml": { - "namespace": "http://www.w3.org/2005/Atom" - }, - "properties": { - "type": { - "description": "MIME type of content.", - "type": "string", - "default": "application/xml", - "xml": { - "attribute": true - } - }, - "TopicDescription": { - "description": "Topic information to create.", - "$ref": "#/definitions/TopicDescription" - } - } - } - } - }, - "EntityAvailabilityStatus": { - "description": "Availibility status of the entity", - "type": "string", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "enum": [ - "Available", - "Limited", - "Renaming", - "Restoring", - "Unknown" - ] - }, - "EntityStatus": { - "description": "Status of a Service Bus resource", - "type": "string", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "enum": [ - "Active", - "Creating", - "Deleting", - "Disabled", - "ReceiveDisabled", - "Renaming", - "Restoring", - "SendDisabled", - "Unknown" - ] - }, - "MessageCountDetails": { - "description": "Details about the message counts in queue.", - "type": "object", - "properties": { - "ActiveMessageCount": { - "description": "Number of active messages in the queue, topic, or subscription.", - "type": "integer", - "xml": { - "prefix": "d2p1", - "namespace": "http://schemas.microsoft.com/netservices/2011/06/servicebus" - } - }, - "DeadLetterMessageCount": { - "description": "Number of messages that are dead lettered.", - "type": "integer", - "xml": { - "prefix": "d2p1", - "namespace": "http://schemas.microsoft.com/netservices/2011/06/servicebus" - } - }, - "ScheduledMessageCount": { - "description": "Number of scheduled messages.", - "type": "integer", - "xml": { - "prefix": "d2p1", - "namespace": "http://schemas.microsoft.com/netservices/2011/06/servicebus" - } - }, - "TransferDeadLetterMessageCount": { - "description": "Number of messages transferred into dead letters.", - "type": "integer", - "xml": { - "prefix": "d2p1", - "namespace": "http://schemas.microsoft.com/netservices/2011/06/servicebus" - } - }, - "TransferMessageCount": { - "description": "Number of messages transferred to another queue, topic, or subscription.", - "type": "integer", - "xml": { - "prefix": "d2p1", - "namespace": "http://schemas.microsoft.com/netservices/2011/06/servicebus" - } - } - }, - "xml": { - "name": "CountDetails", - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "QueueDescription": { - "description": "Description of a Service Bus queue resource.", - "type": "object", - "xml": { - "name": "QueueDescription", - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "properties": { - "AuthorizationRules": { - "description": "Authorization rules for resource.", - "type": "array", - "xml": { - "name": "AuthorizationRules", - "wrapped": true, - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "items": { - "$ref": "#/definitions/AuthorizationRule" - } - }, - "AutoDeleteOnIdle": { - "description": "ISO 8601 timeSpan idle interval after which the queue is automatically deleted. The minimum duration is 5 minutes.", - "type": "string", - "format": "duration", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "CreatedAt": { - "description": "The exact time the queue was created.", - "type": "string", - "format": "date-time", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "DeadLetteringOnMessageExpiration": { - "description": "A value that indicates whether this queue has dead letter support when a message expires.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "DefaultMessageTimeToLive": { - "description": "ISO 8601 default message timespan to live value. This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself.", - "type": "string", - "format": "duration", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "DuplicateDetectionHistoryTimeWindow": { - "description": "ISO 8601 timeSpan structure that defines the duration of the duplicate detection history. The default value is 10 minutes.", - "type": "string", - "format": "duration", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "EntityAvailabilityStatus": { - "$ref": "#/definitions/EntityAvailabilityStatus" - }, - "EnableBatchedOperations": { - "description": "Value that indicates whether server-side batched operations are enabled.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "EnableExpress": { - "description": "A value that indicates whether Express Entities are enabled. An express queue holds a message in memory temporarily before writing it to persistent storage.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "EnablePartitioning": { - "description": "A value that indicates whether the queue is to be partitioned across multiple message brokers.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "IsAnonymousAccessible": { - "description": "A value indicating if the resource can be accessed without authorization.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "LockDuration": { - "description": "ISO 8601 timespan duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. The maximum value for LockDuration is 5 minutes; the default value is 1 minute.", - "type": "string", - "format": "duration", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "MaxDeliveryCount": { - "description": "The maximum delivery count. A message is automatically deadlettered after this number of deliveries. Default value is 10.", - "type": "integer", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "MaxSizeInMegabytes": { - "description": "The maximum size of the queue in megabytes, which is the size of memory allocated for the queue.", - "type": "integer", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "RequiresDuplicateDetection": { - "description": "A value indicating if this queue requires duplicate detection.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "RequiresSession": { - "description": "A value that indicates whether the queue supports the concept of sessions.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "Status": { - "$ref": "#/definitions/EntityStatus" - }, - "SupportOrdering": { - "description": "A value that indicates whether the queue supports ordering.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "AccessedAt": { - "description": "Last time a message was sent, or the last time there was a receive request to this queue.", - "type": "string", - "format": "date-time", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "UpdatedAt": { - "description": "The exact time a message was updated in the queue.", - "type": "string", - "format": "date-time", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "SizeInBytes": { - "description": "The size of the queue, in bytes.", - "type": "integer", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "MessageCount": { - "description": "The number of messages in the queue.", - "type": "integer", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "MessageCountDetails": { - "$ref": "#/definitions/MessageCountDetails" - } - } - }, - "QueueDescriptionEntry": { - "description": "Represents an entry in the feed when querying queues", - "type": "object", - "properties": { - "base": { - "description": "Base URL for the query.", - "type": "string", - "xml": { - "name": "base", - "attribute": true, - "prefix": "xml" - } - }, - "id": { - "description": "The URL of the GET request", - "type": "string" - }, - "title": { - "description": "The name of the queue", - "$ref": "#/definitions/ResponseTitle" - }, - "published": { - "description": "The timestamp for when this queue was published", - "type": "string", - "format": "date-time" - }, - "updated": { - "description": "The timestamp for when this queue was last updated", - "type": "string", - "format": "date-time" - }, - "author": { - "$ref": "#/definitions/ResponseAuthor" - }, - "link": { - "$ref": "#/definitions/ResponseLink" - }, - "content": { - "description": "The QueueDescription", - "type": "object", - "properties": { - "type": { - "description": "Type of content in queue response", - "type": "string", - "xml": { - "attribute": true - } - }, - "QueueDescription": { - "$ref": "#/definitions/QueueDescription" - } - } - } - }, - "xml": { - "name": "entry", - "namespace": "http://www.w3.org/2005/Atom" - } - }, - "QueueDescriptionFeed": { - "description": "Response from listing Service Bus queues.", - "type": "object", - "xml": { - "name": "feed", - "namespace": "http://www.w3.org/2005/Atom" - }, - "properties": { - "id": { - "description": "URL of the list queues query.", - "type": "string" - }, - "title": { - "description": "The entity type for the feed.", - "type": "string" - }, - "updated": { - "description": "Datetime of the query.", - "type": "string", - "format": "date-time" - }, - "link": { - "description": "Links to paginated response.", - "type":"array", - "items": { - "$ref": "#/definitions/ResponseLink" - } - }, - "entry": { - "description": "Queue entries.", - "type": "array", - "items": { - "$ref": "#/definitions/QueueDescriptionEntry" - } - } - } - }, - "QueueDescriptionResponse": { - "description": "The response from a Queue_Get operation", - "type": "object", - "properties": { - "id": { - "description": "The URL of the GET request", - "type": "string" - }, - "title": { - "description": "The name of the queue", - "type": "string" - }, - "published": { - "description": "The timestamp for when this queue was published", - "type": "string" - }, - "updated": { - "description": "The timestamp for when this queue was last updated", - "type": "string" - }, - "author": { - "$ref": "#/definitions/ResponseAuthor" - }, - "link": { - "$ref": "#/definitions/ResponseLink" - }, - "content": { - "description": "Contents of a Queue_Get response", - "type": "object", - "properties": { - "type": { - "description": "Type of content in queue response", - "type": "string", - "xml": { - "attribute": true - } - }, - "QueueDescription": { - "$ref": "#/definitions/QueueDescription" - } - } - } - }, - "xml": { - "name": "entry", - "namespace": "http://www.w3.org/2005/Atom" - } - }, - "ResponseAuthor": { - "description": "The author that created this resource", - "type": "object", - "properties": { - "name": { - "description": "The Service Bus namespace", - "type": "string" - } - } - }, - "ResponseLink": { - "description": "The URL for the HTTP request", - "type": "object", - "properties": { - "href": { - "description": "The URL of the GET request", - "type": "string", - "xml": { - "attribute": true - } - }, - "rel": { - "description": "What the link href is relative to", - "type": "string", - "xml": { - "attribute": true - } - } - }, - "xml": { - "name": "link", - "namespace": "http://www.w3.org/2005/Atom" - } - }, - "ResponseTitle": { - "description": "The title of the response", - "type": "object", - "properties": { - "type": { - "description": "Type of value", - "type": "string", - "xml": { - "attribute": true - } - }, - "title": { - "description": "Contents of the title.", - "type": "string" - } - } - }, - "ServiceBusManagementError": { - "description": "The error response from Service Bus.", - "type": "object", - "properties": { - "Code": { - "description": "The service error code.", - "type": "integer" - }, - "Detail": { - "description": "The service error message.", - "type": "string" - } - } - }, - "TopicDescription": { - "description": "Description of a Service Bus topic resource.", - "type": "object", - "xml": { - "name": "TopicDescription", - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "properties": { - "TopicName": { - "description": "Name of the topic", - "type": "string" - }, - "AuthorizationRules": { - "description": "Authorization rules for resource.", - "type": "array", - "xml": { - "wrapped": true, - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "items": { - "$ref": "#/definitions/AuthorizationRule" - } - }, - "AutoDeleteOnIdle": { - "description": "ISO 8601 timeSpan idle interval after which the topic is automatically deleted. The minimum duration is 5 minutes.", - "type": "string", - "format": "duration", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "DefaultMessageTimeToLive": { - "description": "ISO 8601 default message timespan to live value. This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself.", - "type": "string", - "format": "duration", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "DuplicateDetectionHistoryTimeWindow": { - "description": "ISO 8601 timeSpan structure that defines the duration of the duplicate detection history. The default value is 10 minutes.", - "type": "string", - "format": "duration", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "EnableBatchedOperations": { - "description": "Value that indicates whether server-side batched operations are enabled.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "EnablePartitioning": { - "description": "A value that indicates whether the topic is to be partitioned across multiple message brokers.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "MaxSizeInMegabytes": { - "description": "The maximum size of the topic in megabytes, which is the size of memory allocated for the topic.", - "type": "integer", - "format": "int64" - }, - "RequiresDuplicateDetection": { - "description": "A value indicating if this topic requires duplicate detection.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "Status": { - "$ref": "#/definitions/EntityStatus" - }, - "SupportOrdering": { - "description": "A value that indicates whether the topic supports ordering.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "UserMetadata": { - "description": "Metadata associated with the topic.", - "type": "string" - } - } - } - }, - "responses": { - "ServiceBusManagementErrorResponse": { - "description": "An error occurred. The possible HTTP status, code, and message strings are listed below", - "headers": { - "x-ms-request-id": { - "description": "A server-generated UUID recorded in the analytics logs for troubleshooting and correlation.", - "pattern": "^[{(]?[0-9a-f]{8}[-]?([0-9a-f]{4}[-]?){3}[0-9a-f]{12}[)}]?$", - "type": "string" - }, - "x-ms-version": { - "description": "The version of the REST protocol used to process the request.", - "type": "string" - } - }, - "schema": { - "$ref": "#/definitions/ServiceBusManagementError" - } - } - }, - "paths": { - "/{queueName}": { - "parameters": [ - { - "name": "queueName", - "in": "path", - "description": "The name of the queue relative to the Service Bus namespace.", - "minLength": 1, - "x-ms-parameter-location": "method", - "required": true, - "type": "string" - } - ], - "get": { - "operationId": "Queue_Get", - "summary": "Get Queue", - "description": "Get the details about the Queue with the given queueName.", - "tags": [ - "Queue Operations" - ], - "parameters": [ - { - "$ref": "#/parameters/Enrich" - }, - { - "$ref": "#/parameters/ApiVersion" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object" - } - }, - "default": { - "$ref": "#/responses/ServiceBusManagementErrorResponse" - } - } - }, - "put": { - "tags": [ - "Queue Operations" - ], - "operationId": "Queue_Put", - "description": "Create or update a queue at the provided queuePath", - "parameters": [ - { - "name": "requestBody", - "in": "body", - "schema": { - "type": "object" - }, - "required": true, - "description": "Parameters required to make or edit a queue.", - "x-ms-parameter-location": "method" - }, - { - "$ref": "#/parameters/ApiVersion" - }, - { - "name": "If-Match", - "in": "header", - "required": false, - "type": "string", - "description": "Match condition for an entity to be updated. If specified and a matching entity is not found, an error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, an insert will be performed when no existing entity is found to update and a replace will be performed if an existing entity is found.", - "x-ms-parameter-location": "method" - } - ], - "responses": { - "200": { - "description": "Update -- Update Queue operation completed successfully.", - "schema": { - "type": "object" - } - }, - "201": { - "description": "Created -- Create Queue operation completed successfully.", - "schema": { - "type": "object" - } - }, - "default": { - "$ref": "#/responses/ServiceBusManagementErrorResponse" - } - } - }, - "delete": { - "operationId": "Queue_Delete", - "summary": "Delete Queue", - "description": "Delete the Queue with the given queueName.", - "tags": [ - "Queue Operations" - ], - "parameters": [ - { - "$ref": "#/parameters/ApiVersion" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object" - } - }, - "default": { - "$ref": "#/responses/ServiceBusManagementErrorResponse" - } - } - } - }, - "/$Resources/{entityType}": { - "parameters": [ - { - "name": "entityType", - "in": "path", - "description": "List all queues or all topics of the service bus. Value can be \"queues\" or \"topics\" ", - "minLength": 1, - "x-ms-parameter-location": "method", - "required": true, - "type": "string" - } - ], - "get": { - "operationId": "listEntities", - "summary": "Get Queues or topics", - "description": "Get the details about the entities of the given Service Bus namespace.", - "tags": [ - "Queue Operations", - "Topic Operations" - ], - "parameters": [ - { - "name": "$skip", - "type": "integer", - "in": "query", - "default": 0 - }, - { - "name": "$top", - "type": "integer", - "in": "query", - "default": 100 - }, - { - "$ref": "#/parameters/ApiVersion" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object" - } - }, - "default": { - "$ref": "#/responses/ServiceBusManagementErrorResponse" - } - } - } - } - } -} \ No newline at end of file