diff --git a/sdk/servicebus/azure-servicebus/CHANGELOG.md b/sdk/servicebus/azure-servicebus/CHANGELOG.md index d830e9d4e154..f33371e46ca8 100644 --- a/sdk/servicebus/azure-servicebus/CHANGELOG.md +++ b/sdk/servicebus/azure-servicebus/CHANGELOG.md @@ -1,15 +1,21 @@ # Release History -## 7.8.4 (Unreleased) - -### Features Added +## 7.9.0 (Unreleased) ### Breaking Changes +- Client side validation of input is now disabled by default for the sync and async `ServiceBusAdministrationClient`. This means there will be no `msrest.exceptions.ValidationError` raised by the `ServiceBusAdministrationClient` in the case of malformed input. An `azure.core.exceptions.HttpResponseError` may now be raised if the server refuses the request. + ### Bugs Fixed +- Fixed a bug where enum members in `azure.servicebus.management` were not following uppercase convention. + ### Other Changes +- Updated minimum `azure-core` version to 1.24.0. +- Removed `msrest` dependency. +- Removed `azure-common` dependency. + ## 7.8.3 (2023-03-09) ### Bugs Fixed diff --git a/sdk/servicebus/azure-servicebus/assets.json b/sdk/servicebus/azure-servicebus/assets.json index fae859b6d29b..1b34966de7e8 100644 --- a/sdk/servicebus/azure-servicebus/assets.json +++ b/sdk/servicebus/azure-servicebus/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/servicebus/azure-servicebus", - "Tag": "python/servicebus/azure-servicebus_361137d481" + "Tag": "python/servicebus/azure-servicebus_f69b8e6a3c" } diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_common/utils.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_common/utils.py index 0301d8cb8783..1fd365e9b9a3 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_common/utils.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_common/utils.py @@ -24,7 +24,7 @@ cast ) from contextlib import contextmanager -from msrest.serialization import TZ_UTC +from datetime import timezone try: from urlparse import urlparse @@ -81,11 +81,11 @@ def utc_from_timestamp(timestamp): - return datetime.datetime.fromtimestamp(timestamp, tz=TZ_UTC) + return datetime.datetime.fromtimestamp(timestamp, tz=timezone.utc) def utc_now(): - return datetime.datetime.now(TZ_UTC) + return datetime.datetime.now(timezone.utc) def build_uri(address, entity): diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_version.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_version.py index b2df64baeb85..c7dc12823bbc 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_version.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_version.py @@ -3,4 +3,4 @@ # Licensed under the MIT License. # ------------------------------------ -VERSION = "7.8.4" +VERSION = "7.9.0" 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 index 92b1e9e8f735..c16816d9e8d1 100644 --- 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 @@ -25,13 +25,18 @@ from ...management._generated.models import ( QueueDescriptionFeed, + QueueDescriptionEntryContent, TopicDescriptionEntry, + TopicDescriptionEntryContent, QueueDescriptionEntry, SubscriptionDescriptionFeed, SubscriptionDescriptionEntry, + SubscriptionDescriptionEntryContent, RuleDescriptionEntry, RuleDescriptionFeed, + RuleDescriptionEntryContent, NamespacePropertiesEntry, + NamespacePropertiesEntryContent, CreateTopicBody, CreateTopicBodyContent, TopicDescriptionFeed, @@ -53,10 +58,10 @@ ServiceBusSharedKeyCredential, ServiceBusSASTokenCredential, ) -from ...management._generated.aio._configuration_async import ( +from ...management._generated.aio._configuration import ( ServiceBusManagementClientConfiguration, ) -from ...management._generated.aio._service_bus_management_client_async import ( +from ...management._generated.aio import ( ServiceBusManagementClient as ServiceBusManagementClientImpl, ) from ...management import _constants as constants @@ -114,15 +119,23 @@ def __init__( api_version: Union[str, ApiVersion] = DEFAULT_VERSION, **kwargs: Any ) -> None: - self.fully_qualified_namespace = fully_qualified_namespace self._api_version = api_version self._credential = credential self._endpoint = "https://" + fully_qualified_namespace - self._config = ServiceBusManagementClientConfiguration(self._endpoint, **kwargs) + self._config = ServiceBusManagementClientConfiguration( + self._endpoint, + credential=self._credential, + api_version=api_version, + **kwargs + ) self._pipeline = self._build_pipeline() self._impl = ServiceBusManagementClientImpl( - endpoint=fully_qualified_namespace, pipeline=self._pipeline + endpoint=fully_qualified_namespace, + credential=self._credential, + pipeline=self._pipeline, + api_version=api_version, + **kwargs ) async def __aenter__(self) -> "ServiceBusAdministrationClient": @@ -169,9 +182,7 @@ async def _get_entity_element( with _handle_response_error(): element = cast( ElementTree, - await self._impl.entity.get( - entity_name, enrich=enrich, api_version=self._api_version, **kwargs - ), + await self._impl.entity.get(entity_name, enrich=enrich, **kwargs), ) return element @@ -188,11 +199,7 @@ async def _get_subscription_element( element = cast( ElementTree, await self._impl.subscription.get( - topic_name, - subscription_name, - enrich=enrich, - api_version=self._api_version, - **kwargs + topic_name, subscription_name, enrich=enrich, **kwargs ), ) return element @@ -208,12 +215,7 @@ async def _get_rule_element( element = cast( ElementTree, await self._impl.rule.get( - topic_name, - subscription_name, - rule_name, - enrich=False, - api_version=self._api_version, - **kwargs + topic_name, subscription_name, rule_name, enrich=False, **kwargs ), ) return element @@ -439,14 +441,14 @@ async def create_queue( # pylint: disable=too-many-locals entry_ele = cast( ElementTree, await self._impl.entity.put( - queue_name, # type: ignore - request_body, - api_version=self._api_version, - **kwargs + queue_name, request_body, **kwargs # type: ignore ), ) entry = QueueDescriptionEntry.deserialize(entry_ele) + # Need to cast from Optional[QueueDescriptionEntryContent] to QueueDescriptionEntryContent + # since we know for certain that `entry.content` will not be None here. + entry.content = cast(QueueDescriptionEntryContent, entry.content) result = QueueProperties._from_internal_entity( queue_name, entry.content.queue_description ) @@ -482,11 +484,7 @@ async def update_queue( await self._create_forward_to_header_tokens(to_update, kwargs) with _handle_response_error(): await self._impl.entity.put( - queue.name, # type: ignore - request_body, - api_version=self._api_version, - if_match="*", - **kwargs + queue.name, request_body, if_match="*", **kwargs # type: ignore ) async def delete_queue(self, queue_name: str, **kwargs: Any) -> None: @@ -501,9 +499,7 @@ async def delete_queue(self, queue_name: str, **kwargs: Any) -> None: 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=self._api_version, **kwargs - ) + await self._impl.entity.delete(queue_name, **kwargs) def list_queues(self, **kwargs: Any) -> AsyncItemPaged[QueueProperties]: """List the queues of a ServiceBus namespace. @@ -524,7 +520,6 @@ def entry_to_qd(entry): get_next = functools.partial( get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_QUEUES), - api_version=self._api_version, **kwargs ) return AsyncItemPaged(get_next, extract_data) @@ -550,7 +545,6 @@ def entry_to_qr(entry): get_next = functools.partial( get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_QUEUES), - api_version=self._api_version, **kwargs ) return AsyncItemPaged(get_next, extract_data) @@ -694,13 +688,13 @@ async def create_topic( entry_ele = cast( ElementTree, await self._impl.entity.put( - topic_name, # type: ignore - request_body, - api_version=self._api_version, - **kwargs + topic_name, request_body, **kwargs # type: ignore ), ) entry = TopicDescriptionEntry.deserialize(entry_ele) + # Need to cast from Optional[TopicDescriptionEntryContent] to TopicDescriptionEntryContent + # since we know for certain that `entry.content` will not be None here. + entry.content = cast(TopicDescriptionEntryContent, entry.content) result = TopicProperties._from_internal_entity( topic_name, entry.content.topic_description ) @@ -735,11 +729,7 @@ async def update_topic( request_body = create_entity_body.serialize(is_xml=True) with _handle_response_error(): await self._impl.entity.put( - topic.name, # type: ignore - request_body, - api_version=self._api_version, - if_match="*", - **kwargs + topic.name, request_body, if_match="*", **kwargs # type: ignore ) async def delete_topic(self, topic_name: str, **kwargs: Any) -> None: @@ -750,9 +740,7 @@ async def delete_topic(self, topic_name: str, **kwargs: Any) -> None: """ _validate_entity_name_type(topic_name) - await self._impl.entity.delete( - topic_name, api_version=self._api_version, **kwargs - ) + await self._impl.entity.delete(topic_name, **kwargs) def list_topics(self, **kwargs: Any) -> AsyncItemPaged[TopicProperties]: """List the topics of a ServiceBus namespace. @@ -773,7 +761,6 @@ def entry_to_topic(entry): get_next = functools.partial( get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_TOPICS), - api_version=self._api_version, **kwargs ) return AsyncItemPaged(get_next, extract_data) @@ -799,7 +786,6 @@ def entry_to_topic(entry): get_next = functools.partial( get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_TOPICS), - api_version=self._api_version, **kwargs ) return AsyncItemPaged(get_next, extract_data) @@ -824,7 +810,8 @@ async def get_subscription( ) ) subscription = SubscriptionProperties._from_internal_entity( - entry.title, entry.content.subscription_description + subscription_name, + entry.content.subscription_description ) return subscription @@ -848,7 +835,8 @@ async def get_subscription_runtime_properties( ) ) subscription = SubscriptionRuntimeProperties._from_internal_entity( - entry.title, entry.content.subscription_description + subscription_name, + entry.content.subscription_description ) return subscription @@ -960,14 +948,17 @@ async def create_subscription( topic_name, subscription_name, # type: ignore request_body, - api_version=self._api_version, **kwargs ), ) entry = SubscriptionDescriptionEntry.deserialize(entry_ele) + # Need to cast from Optional[SubscriptionDescriptionEntryContent] to SubscriptionDescriptionEntryContent + # since we know for certain that `entry.content` will not be None here. + entry.content = cast(SubscriptionDescriptionEntryContent, entry.content) result = SubscriptionProperties._from_internal_entity( - subscription_name, entry.content.subscription_description + subscription_name, + entry.content.subscription_description ) return result @@ -1010,12 +1001,7 @@ async def update_subscription( await self._create_forward_to_header_tokens(to_update, kwargs) with _handle_response_error(): await self._impl.subscription.put( - topic_name, - subscription.name, - request_body, - api_version=self._api_version, - if_match="*", - **kwargs + topic_name, subscription.name, request_body, if_match="*", **kwargs ) async def delete_subscription( @@ -1030,9 +1016,7 @@ async def delete_subscription( """ _validate_topic_and_subscription_types(topic_name, subscription_name) - await self._impl.subscription.delete( - topic_name, subscription_name, api_version=self._api_version, **kwargs - ) + await self._impl.subscription.delete(topic_name, subscription_name, **kwargs) def list_subscriptions( self, topic_name: str, **kwargs: Any @@ -1057,7 +1041,6 @@ def entry_to_subscription(entry): get_next = functools.partial( get_next_template, functools.partial(self._impl.list_subscriptions, topic_name), - api_version=self._api_version, **kwargs ) return AsyncItemPaged(get_next, extract_data) @@ -1085,7 +1068,6 @@ def entry_to_subscription(entry): get_next = functools.partial( get_next_template, functools.partial(self._impl.list_subscriptions, topic_name), - api_version=self._api_version, **kwargs ) return AsyncItemPaged(get_next, extract_data) @@ -1170,10 +1152,12 @@ async def create_rule( subscription_name, # type: ignore rule_name, request_body, - api_version=self._api_version, **kwargs ) entry = RuleDescriptionEntry.deserialize(entry_ele) + # Need to cast from Optional[RuleDescriptionEntryContent] to RuleDescriptionEntryContent + # since we know for certain that `entry.content` will not be None here. + entry.content = cast(RuleDescriptionEntryContent, entry.content) result = RuleProperties._from_internal_entity( rule_name, entry.content.rule_description ) @@ -1223,7 +1207,6 @@ async def update_rule( subscription_name, rule.name, request_body, - api_version=self._api_version, if_match="*", **kwargs ) @@ -1243,13 +1226,7 @@ async def delete_rule( topic_name, subscription_name, rule_name ) - await self._impl.rule.delete( - topic_name, - subscription_name, - rule_name, - api_version=self._api_version, - **kwargs - ) + await self._impl.rule.delete(topic_name, subscription_name, rule_name, **kwargs) def list_rules( self, topic_name: str, subscription_name: str, **kwargs: Any @@ -1281,7 +1258,6 @@ def entry_to_rule(ele, entry): get_next = functools.partial( get_next_template, functools.partial(self._impl.list_rules, topic_name, subscription_name), - api_version=self._api_version, **kwargs ) return AsyncItemPaged(get_next, extract_data) @@ -1291,12 +1267,12 @@ async def get_namespace_properties(self, **kwargs: Any) -> NamespaceProperties: :rtype: ~azure.servicebus.management.NamespaceProperties """ - entry_el = await self._impl.namespace.get( - api_version=self._api_version, **kwargs - ) + entry_el = await self._impl.namespace.get(**kwargs) namespace_entry = NamespacePropertiesEntry.deserialize(entry_el) + namespace_entry.content = cast(NamespacePropertiesEntryContent, namespace_entry.content) return NamespaceProperties._from_internal_entity( - namespace_entry.title, namespace_entry.content.namespace_properties + namespace_entry.title, + namespace_entry.content.namespace_properties ) async def close(self) -> None: diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/_utils.py b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/_utils.py index 345bc93f0966..38c784025abf 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/_utils.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/management/_utils.py @@ -9,7 +9,6 @@ import urllib.parse as urlparse from ...management import _constants as constants -from ...management._api_version import DEFAULT_VERSION from ...management._handle_response_error import _handle_response_error # This module defines functions get_next_template and extract_data_template. @@ -127,17 +126,13 @@ async def get_next_template( XML ElementTree to call a partial function created from `extrat_data_template`. """ - api_version = kwargs.pop("api_version", DEFAULT_VERSION) if args[0]: # It's next link. It's None for the first page. queries = urlparse.parse_qs(urlparse.urlparse(args[0]).query) start_index = int(queries[constants.LIST_OP_SKIP][0]) max_page_size = int(queries[constants.LIST_OP_TOP][0]) - api_version = queries[constants.API_VERSION_PARAM_NAME][0] with _handle_response_error(): feed_element = cast( ElementTree, - await list_func( - skip=start_index, top=max_page_size, api_version=api_version, **kwargs - ), + await list_func(skip=start_index, top=max_page_size, **kwargs), ) return feed_element diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/amqp/_amqp_message.py b/sdk/servicebus/azure-servicebus/azure/servicebus/amqp/_amqp_message.py index 76c258dc1a14..6e3293e3921f 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/amqp/_amqp_message.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/amqp/_amqp_message.py @@ -11,7 +11,7 @@ import warnings from typing import Optional, Any, Tuple, cast, Mapping, Union, Dict, List -from msrest.serialization import TZ_UTC +from datetime import timezone import uamqp from ._constants import AMQP_MESSAGE_BODY_TYPE_MAP, AmqpMessageBodyType @@ -226,7 +226,7 @@ def _to_outgoing_amqp_message(self): message_header.priority = self.header.priority if self.header.time_to_live and self.header.time_to_live != MAX_DURATION_VALUE: ttl_set = True - creation_time_from_ttl = int(time.mktime(datetime.now(TZ_UTC).timetuple()) * 1000) + creation_time_from_ttl = int(time.mktime(datetime.now(timezone.utc).timetuple()) * 1000) absolute_expiry_time_from_ttl = int(min( MAX_ABSOLUTE_EXPIRY_TIME, creation_time_from_ttl + self.header.time_to_live diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/__init__.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/__init__.py index 3b8589d926af..19a1ff774d4d 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/__init__.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/__init__.py @@ -6,14 +6,18 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._service_bus_management_client import ServiceBusManagementClient -from ._version import VERSION - -__version__ = VERSION -__all__ = ['ServiceBusManagementClient'] +from ._client import ServiceBusManagementClient try: - from ._patch import patch_sdk - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ServiceBusManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_client.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_client.py new file mode 100644 index 000000000000..286db3e51e6f --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_client.py @@ -0,0 +1,101 @@ +# 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 copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core import PipelineClient +from azure.core.rest import HttpRequest, HttpResponse + +from . import models as _models +from ._configuration import ServiceBusManagementClientConfiguration +from ._serialization import Deserializer, Serializer +from .operations import ( + EntityOperations, + NamespaceOperations, + RuleOperations, + ServiceBusManagementClientOperationsMixin, + SubscriptionOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class ServiceBusManagementClient( + ServiceBusManagementClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword + """Azure Service Bus client for managing Queues, Topics, and Subscriptions. + + :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. Required. + :type endpoint: str + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :keyword api_version: Api Version. Default value is "2021-05". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: + _endpoint = "https://{endpoint}" + self._config = ServiceBusManagementClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + self._client: PipelineClient = PipelineClient(base_url=_endpoint, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + 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 send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "ServiceBusManagementClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_configuration.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_configuration.py index 4608ce854384..6df9f8728a8f 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_configuration.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_configuration.py @@ -6,52 +6,66 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import sys +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional + from azure.core.credentials import TokenCredential +VERSION = "unknown" -class ServiceBusManagementClientConfiguration(Configuration): + +class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for ServiceBusManagementClient. Note that all parameters used to create this instance are saved as instance attributes. - :param endpoint: The Service Bus fully qualified domain name. + :param endpoint: The Service Bus fully qualified domain name. Required. :type endpoint: str + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :keyword api_version: Api Version. Default value is "2021-05". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - endpoint, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: + super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2021-05"] = kwargs.pop("api_version", "2021-05") + if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") - super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") self.endpoint = endpoint - kwargs.setdefault('sdk_moniker', 'servicebusmanagementclient/{}'.format(VERSION)) + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["user_impersonation"]) + kwargs.setdefault("sdk_moniker", "servicebusmanagementclient/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs # type: Any - ): - # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_patch.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_serialization.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_serialization.py new file mode 100644 index 000000000000..842ae727fbbc --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_serialization.py @@ -0,0 +1,1996 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.serialization import NULL as AzureCoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str + unicode_str = str + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset # type: ignore +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Dict[str, Any] = {} + for k in kwargs: + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes.""" + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes.""" + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node.""" + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to azure from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) + + @classmethod + def from_dict( + cls: Type[ModelType], + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> ModelType: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + Remove the polymorphic key from the initial data. + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + """ + return key.replace("\\.", ".") + + +class Serializer(object): + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is AzureCoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback(SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map # type: ignore + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj 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 deleted file mode 100644 index ee7515cab3ce..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_service_bus_management_client.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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 - -from azure.core import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - -from ._configuration import ServiceBusManagementClientConfiguration -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 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. - """ - - def __init__( - self, - endpoint, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - base_url = 'https://{endpoint}' - self._config = ServiceBusManagementClientConfiguration(endpoint, **kwargs) - self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - 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): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> ServiceBusManagementClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_vendor.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_vendor.py new file mode 100644 index 000000000000..805344916360 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_vendor.py @@ -0,0 +1,38 @@ +# -------------------------------------------------------------------------- +# 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 abc import ABC +from typing import List, TYPE_CHECKING, cast + +from ._configuration import ServiceBusManagementClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import PipelineClient + + from ._serialization import Deserializer, Serializer + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) + + +class ServiceBusManagementClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: ServiceBusManagementClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_version.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_version.py deleted file mode 100644 index d1e365c2c71f..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -VERSION = "2021-05" diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/__init__.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/__init__.py index 693d0204300b..19a1ff774d4d 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/__init__.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/__init__.py @@ -6,5 +6,18 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._service_bus_management_client_async import ServiceBusManagementClient -__all__ = ['ServiceBusManagementClient'] +from ._client import ServiceBusManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ServiceBusManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_client.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_client.py new file mode 100644 index 000000000000..57e1f10b6bb4 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_client.py @@ -0,0 +1,102 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest + +from .. import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import ServiceBusManagementClientConfiguration +from .operations import ( + EntityOperations, + NamespaceOperations, + RuleOperations, + ServiceBusManagementClientOperationsMixin, + SubscriptionOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ServiceBusManagementClient( + ServiceBusManagementClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword + """Azure Service Bus client for managing Queues, Topics, and Subscriptions. + + :ivar entity: EntityOperations operations + :vartype entity: azure.servicebus.management._generated.aio.operations.EntityOperations + :ivar subscription: SubscriptionOperations operations + :vartype subscription: + azure.servicebus.management._generated.aio.operations.SubscriptionOperations + :ivar rule: RuleOperations operations + :vartype rule: azure.servicebus.management._generated.aio.operations.RuleOperations + :ivar namespace: NamespaceOperations operations + :vartype namespace: azure.servicebus.management._generated.aio.operations.NamespaceOperations + :param endpoint: The Service Bus fully qualified domain name. Required. + :type endpoint: str + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword api_version: Api Version. Default value is "2021-05". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + _endpoint = "https://{endpoint}" + self._config = ServiceBusManagementClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + 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 send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ServiceBusManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_configuration.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_configuration.py new file mode 100644 index 000000000000..62912fe1e250 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_configuration.py @@ -0,0 +1,71 @@ +# 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. +# -------------------------------------------------------------------------- + +import sys +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + + +class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ServiceBusManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: The Service Bus fully qualified domain name. Required. + :type endpoint: str + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword api_version: Api Version. Default value is "2021-05". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2021-05"] = kwargs.pop("api_version", "2021-05") + + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.endpoint = endpoint + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["user_impersonation"]) + kwargs.setdefault("sdk_moniker", "servicebusmanagementclient/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_configuration_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_configuration_async.py deleted file mode 100644 index 1be56d2ea6fe..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_configuration_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# 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, Optional - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies - -from .._version import VERSION - - -class ServiceBusManagementClientConfiguration(Configuration): - """Configuration for ServiceBusManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param endpoint: The Service Bus fully qualified domain name. - :type endpoint: str - """ - - def __init__( - self, - endpoint: str, - **kwargs: Any - ) -> None: - if endpoint is None: - raise ValueError("Parameter 'endpoint' must not be None.") - super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - - self.endpoint = endpoint - kwargs.setdefault('sdk_moniker', 'servicebusmanagementclient/{}'.format(VERSION)) - self._configure(**kwargs) - - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_patch.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 deleted file mode 100644 index 196e6e457645..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_service_bus_management_client_async.py +++ /dev/null @@ -1,69 +0,0 @@ -# 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, Optional - -from azure.core import AsyncPipelineClient -from msrest import Deserializer, Serializer - -from ._configuration_async import ServiceBusManagementClientConfiguration -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 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. - """ - - def __init__( - self, - endpoint: str, - **kwargs: Any - ) -> None: - base_url = 'https://{endpoint}' - self._config = ServiceBusManagementClientConfiguration(endpoint, **kwargs) - self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - 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: - await self._client.close() - - async def __aenter__(self) -> "ServiceBusManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_vendor.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_vendor.py new file mode 100644 index 000000000000..7d5cd71d9cd2 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/_vendor.py @@ -0,0 +1,26 @@ +# -------------------------------------------------------------------------- +# 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 abc import ABC +from typing import TYPE_CHECKING + +from ._configuration import ServiceBusManagementClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import AsyncPipelineClient + + from .._serialization import Deserializer, Serializer + + +class ServiceBusManagementClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: ServiceBusManagementClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations/__init__.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations/__init__.py new file mode 100644 index 000000000000..31eac47d430f --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations/__init__.py @@ -0,0 +1,27 @@ +# 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 ._operations import EntityOperations +from ._operations import ServiceBusManagementClientOperationsMixin +from ._operations import SubscriptionOperations +from ._operations import RuleOperations +from ._operations import NamespaceOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "EntityOperations", + "ServiceBusManagementClientOperationsMixin", + "SubscriptionOperations", + "RuleOperations", + "NamespaceOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations/_operations.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations/_operations.py new file mode 100644 index 000000000000..1c4ab0262572 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations/_operations.py @@ -0,0 +1,974 @@ +# pylint: disable=too-many-lines +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict + +from ... import models as _models +from ...operations._operations import ( + build_entity_delete_request, + build_entity_get_request, + build_entity_put_request, + build_namespace_get_request, + build_rule_delete_request, + build_rule_get_request, + build_rule_put_request, + build_service_bus_management_list_entities_request, + build_service_bus_management_list_rules_request, + build_service_bus_management_list_subscriptions_request, + build_subscription_delete_request, + build_subscription_get_request, + build_subscription_put_request, +) +from .._vendor import ServiceBusManagementClientMixinABC + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class EntityOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.servicebus.management._generated.aio.ServiceBusManagementClient`'s + :attr:`entity` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, entity_name: str, *, enrich: bool = False, **kwargs: Any) -> JSON: + """Get Queue or Topic. + + Get the details about the Queue or Topic with the given entityName. + + :param entity_name: The name of the queue or topic relative to the Service Bus namespace. + Required. + :type entity_name: str + :keyword enrich: A query parameter that sets enrich to true or false. Default value is False. + :paramtype enrich: bool + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_entity_get_request( + entity_name=entity_name, + enrich=enrich, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace_async + async def put(self, entity_name: str, request_body: JSON, *, if_match: Optional[str] = None, **kwargs: Any) -> JSON: + """Create or update a queue or topic at the provided entityName. + + :param entity_name: The name of the queue or topic relative to the Service Bus namespace. + Required. + :type entity_name: str + :param request_body: Parameters required to make or edit a queue or topic. Required. + :type request_body: JSON + :keyword 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. Default + value is None. + :paramtype if_match: str + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/atom+xml")) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _content = self._serialize.body(request_body, "object") + + request = build_entity_put_request( + entity_name=entity_name, + if_match=if_match, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + 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, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, entity_name: str, **kwargs: Any) -> JSON: + """Delete Queue or Topic. + + Delete the Queue or Topic with the given entityName. + + :param entity_name: The name of the queue or topic relative to the Service Bus namespace. + Required. + :type entity_name: str + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_entity_delete_request( + entity_name=entity_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class ServiceBusManagementClientOperationsMixin(ServiceBusManagementClientMixinABC): + @distributed_trace_async + async def list_subscriptions(self, topic_name: str, *, skip: int = 0, top: int = 100, **kwargs: Any) -> JSON: + """Get subscriptions. + + Get the details about the subscriptions of the given topic. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :keyword skip: Default value is 0. + :paramtype skip: int + :keyword top: Default value is 100. + :paramtype top: int + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_service_bus_management_list_subscriptions_request( + topic_name=topic_name, + skip=skip, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace_async + async def list_rules( + self, topic_name: str, subscription_name: str, *, skip: int = 0, top: int = 100, **kwargs: Any + ) -> JSON: + """Get rules of a topic subscription. + + Get the details about the rules of the given topic subscription. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :param subscription_name: name of the subscription. Required. + :type subscription_name: str + :keyword skip: Default value is 0. + :paramtype skip: int + :keyword top: Default value is 100. + :paramtype top: int + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_service_bus_management_list_rules_request( + topic_name=topic_name, + subscription_name=subscription_name, + skip=skip, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace_async + async def list_entities(self, entity_type: str, *, skip: int = 0, top: int = 100, **kwargs: Any) -> JSON: + """Get Queues or topics. + + Get the details about the entities of the given Service Bus namespace. + + :param entity_type: List all queues or all topics of the service bus. Value can be "queues" or + "topics". Required. + :type entity_type: str + :keyword skip: Default value is 0. + :paramtype skip: int + :keyword top: Default value is 100. + :paramtype top: int + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_service_bus_management_list_entities_request( + entity_type=entity_type, + skip=skip, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class SubscriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.servicebus.management._generated.aio.ServiceBusManagementClient`'s + :attr:`subscription` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, topic_name: str, subscription_name: str, *, enrich: bool = False, **kwargs: Any) -> JSON: + """Get Subscription. + + Get the details about the subscription of a topic. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :param subscription_name: name of the subscription. Required. + :type subscription_name: str + :keyword enrich: A query parameter that sets enrich to true or false. Default value is False. + :paramtype enrich: bool + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_subscription_get_request( + topic_name=topic_name, + subscription_name=subscription_name, + enrich=enrich, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace_async + async def put( + self, + topic_name: str, + subscription_name: str, + request_body: JSON, + *, + if_match: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Create or update a subscription. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :param subscription_name: name of the subscription. Required. + :type subscription_name: str + :param request_body: Parameters required to make or edit a subscription. Required. + :type request_body: JSON + :keyword 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. Default + value is None. + :paramtype if_match: str + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/atom+xml")) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _content = self._serialize.body(request_body, "object") + + request = build_subscription_put_request( + topic_name=topic_name, + subscription_name=subscription_name, + if_match=if_match, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + 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, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, topic_name: str, subscription_name: str, **kwargs: Any) -> JSON: + """Delete Subscription. + + Delete the subscription with the given topicName and subscriptionName. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :param subscription_name: name of the subscription. Required. + :type subscription_name: str + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_subscription_delete_request( + topic_name=topic_name, + subscription_name=subscription_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class RuleOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.servicebus.management._generated.aio.ServiceBusManagementClient`'s + :attr:`rule` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, topic_name: str, subscription_name: str, rule_name: str, *, enrich: bool = False, **kwargs: Any + ) -> JSON: + """Get Rule. + + Get the details about the rule of a subscription of a topic. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :param subscription_name: name of the subscription. Required. + :type subscription_name: str + :param rule_name: name of the filter. Required. + :type rule_name: str + :keyword enrich: A query parameter that sets enrich to true or false. Default value is False. + :paramtype enrich: bool + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_rule_get_request( + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + enrich=enrich, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace_async + async def put( + self, + topic_name: str, + subscription_name: str, + rule_name: str, + request_body: JSON, + *, + if_match: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Create or update a rule. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :param subscription_name: name of the subscription. Required. + :type subscription_name: str + :param rule_name: name of the filter. Required. + :type rule_name: str + :param request_body: Parameters required to make or edit a rule. Required. + :type request_body: JSON + :keyword 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. Default + value is None. + :paramtype if_match: str + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/atom+xml")) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _content = self._serialize.body(request_body, "object") + + request = build_rule_put_request( + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + if_match=if_match, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + 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, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, topic_name: str, subscription_name: str, rule_name: str, **kwargs: Any) -> JSON: + """Delete Subscription. + + Delete the rule with the given topicName, subscriptionName and ruleName. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :param subscription_name: name of the subscription. Required. + :type subscription_name: str + :param rule_name: name of the filter. Required. + :type rule_name: str + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_rule_delete_request( + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class NamespaceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.servicebus.management._generated.aio.ServiceBusManagementClient`'s + :attr:`namespace` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, **kwargs: Any) -> _models.NamespacePropertiesEntry: + """Get Namespace Properties. + + Get the details about the Service Bus namespace. + + :return: NamespacePropertiesEntry + :rtype: ~azure.servicebus.management._generated.models.NamespacePropertiesEntry + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NamespacePropertiesEntry] = kwargs.pop("cls", None) + + request = build_namespace_get_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("NamespacePropertiesEntry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations/_patch.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 deleted file mode 100644 index 04ebe619db3e..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# 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 ._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__ = [ - 'EntityOperations', - 'ServiceBusManagementClientOperationsMixin', - 'SubscriptionOperations', - 'RuleOperations', - 'NamespaceOperations', -] diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_entity_operations_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_entity_operations_async.py deleted file mode 100644 index a45b77527d1f..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_entity_operations_async.py +++ /dev/null @@ -1,239 +0,0 @@ -# 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 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. - - :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, - entity_name: str, - enrich: Optional[bool] = False, - api_version: Optional[str] = "2021_05", - **kwargs - ) -> object: - """Get the details about the Queue or Topic with the given entityName. - - Get Queue or Topic. - - :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. - :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), - 'entityName': self._serialize.url("entity_name", entity_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': '/{entityName}'} # type: ignore - - async def put( - self, - entity_name: str, - request_body: object, - api_version: Optional[str] = "2021_05", - if_match: Optional[str] = None, - **kwargs - ) -> object: - """Create or update a queue or topic at the provided entityName. - - :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 - :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), - 'entityName': self._serialize.url("entity_name", entity_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': '/{entityName}'} # type: ignore - - async def delete( - self, - entity_name: str, - api_version: Optional[str] = "2021_05", - **kwargs - ) -> object: - """Delete the Queue or Topic with the given entityName. - - Delete Queue or Topic. - - :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 - :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), - 'entityName': self._serialize.url("entity_name", entity_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': '/{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 deleted file mode 100644 index 1f46fcbc42f3..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_namespace_operations_async.py +++ /dev/null @@ -1,94 +0,0 @@ -# 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] = "2021_05", - **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 deleted file mode 100644 index 69538ab2d515..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_rule_operations_async.py +++ /dev/null @@ -1,263 +0,0 @@ -# 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] = "2021_05", - **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] = "2021_05", - 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] = "2021_05", - **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 deleted file mode 100644 index 70dd61415d1d..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_service_bus_management_client_operations_async.py +++ /dev/null @@ -1,229 +0,0 @@ -# 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 ServiceBusManagementClientOperationsMixin: - - async def list_subscriptions( - self, - topic_name: str, - skip: Optional[int] = 0, - top: Optional[int] = 100, - api_version: Optional[str] = "2021_05", - **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] = "2021_05", - **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, - skip: Optional[int] = 0, - top: Optional[int] = 100, - api_version: Optional[str] = "2021_05", - **kwargs - ) -> object: - """Get the details about the entities of the given Service Bus namespace. - - Get Queues or topics. - - :param entity_type: List all queues or all topics of the service bus. Value can be "queues" or - "topics". - :type entity_type: 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_entities.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'entityType': self._serialize.url("entity_type", entity_type, '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_entities.metadata = {'url': '/$Resources/{entityType}'} # type: ignore 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 deleted file mode 100644 index 5d758424aa17..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/aio/operations_async/_subscription_operations_async.py +++ /dev/null @@ -1,251 +0,0 @@ -# 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] = "2021_05", - **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] = "2021_05", - 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] = "2021_05", - **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 17337fa2c371..fd880551c79d 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 @@ -6,144 +6,104 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -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 ResponseAuthor - from ._models_py3 import ResponseLink - 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 ResponseAuthor # type: ignore - from ._models import ResponseLink # 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 ._models import AuthorizationRule +from ._models import CorrelationFilter +from ._models import CreateQueueBody +from ._models import CreateQueueBodyContent +from ._models import CreateRuleBody +from ._models import CreateRuleBodyContent +from ._models import CreateSubscriptionBody +from ._models import CreateSubscriptionBodyContent +from ._models import CreateTopicBody +from ._models import CreateTopicBodyContent +from ._models import EmptyRuleAction +from ._models import FalseFilter +from ._models import KeyValue +from ._models import MessageCountDetails +from ._models import NamespaceProperties +from ._models import NamespacePropertiesEntry +from ._models import NamespacePropertiesEntryContent +from ._models import QueueDescription +from ._models import QueueDescriptionEntry +from ._models import QueueDescriptionEntryContent +from ._models import QueueDescriptionFeed +from ._models import ResponseAuthor +from ._models import ResponseLink +from ._models import RuleAction +from ._models import RuleDescription +from ._models import RuleDescriptionEntry +from ._models import RuleDescriptionEntryContent +from ._models import RuleDescriptionFeed +from ._models import RuleFilter +from ._models import ServiceBusManagementError +from ._models import SqlFilter +from ._models import SqlRuleAction +from ._models import SubscriptionDescription +from ._models import SubscriptionDescriptionEntry +from ._models import SubscriptionDescriptionEntryContent +from ._models import SubscriptionDescriptionFeed +from ._models import TopicDescription +from ._models import TopicDescriptionEntry +from ._models import TopicDescriptionEntryContent +from ._models import TopicDescriptionFeed +from ._models import TrueFilter -from ._service_bus_management_client_enums import ( - AccessRights, - EntityAvailabilityStatus, - EntityStatus, - MessagingSku, - NamespaceType, -) +from ._enums import AccessRights +from ._enums import EntityAvailabilityStatus +from ._enums import EntityStatus +from ._enums import MessagingSku +from ._enums import NamespaceType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AuthorizationRule', - 'CorrelationFilter', - 'CreateQueueBody', - 'CreateQueueBodyContent', - 'CreateRuleBody', - 'CreateRuleBodyContent', - 'CreateSubscriptionBody', - 'CreateSubscriptionBodyContent', - 'CreateTopicBody', - 'CreateTopicBodyContent', - 'EmptyRuleAction', - 'FalseFilter', - 'KeyValue', - 'MessageCountDetails', - 'NamespaceProperties', - 'NamespacePropertiesEntry', - 'NamespacePropertiesEntryContent', - 'QueueDescription', - 'QueueDescriptionEntry', - 'QueueDescriptionEntryContent', - 'QueueDescriptionFeed', - 'ResponseAuthor', - 'ResponseLink', - 'RuleAction', - 'RuleDescription', - 'RuleDescriptionEntry', - 'RuleDescriptionEntryContent', - 'RuleDescriptionFeed', - 'RuleFilter', - 'ServiceBusManagementError', - 'SqlFilter', - 'SqlRuleAction', - 'SubscriptionDescription', - 'SubscriptionDescriptionEntry', - 'SubscriptionDescriptionEntryContent', - 'SubscriptionDescriptionFeed', - 'TopicDescription', - 'TopicDescriptionEntry', - 'TopicDescriptionEntryContent', - 'TopicDescriptionFeed', - 'TrueFilter', - 'AccessRights', - 'EntityAvailabilityStatus', - 'EntityStatus', - 'MessagingSku', - 'NamespaceType', + "AuthorizationRule", + "CorrelationFilter", + "CreateQueueBody", + "CreateQueueBodyContent", + "CreateRuleBody", + "CreateRuleBodyContent", + "CreateSubscriptionBody", + "CreateSubscriptionBodyContent", + "CreateTopicBody", + "CreateTopicBodyContent", + "EmptyRuleAction", + "FalseFilter", + "KeyValue", + "MessageCountDetails", + "NamespaceProperties", + "NamespacePropertiesEntry", + "NamespacePropertiesEntryContent", + "QueueDescription", + "QueueDescriptionEntry", + "QueueDescriptionEntryContent", + "QueueDescriptionFeed", + "ResponseAuthor", + "ResponseLink", + "RuleAction", + "RuleDescription", + "RuleDescriptionEntry", + "RuleDescriptionEntryContent", + "RuleDescriptionFeed", + "RuleFilter", + "ServiceBusManagementError", + "SqlFilter", + "SqlRuleAction", + "SubscriptionDescription", + "SubscriptionDescriptionEntry", + "SubscriptionDescriptionEntryContent", + "SubscriptionDescriptionFeed", + "TopicDescription", + "TopicDescriptionEntry", + "TopicDescriptionEntryContent", + "TopicDescriptionFeed", + "TrueFilter", + "AccessRights", + "EntityAvailabilityStatus", + "EntityStatus", + "MessagingSku", + "NamespaceType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_enums.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_enums.py new file mode 100644 index 000000000000..f34ebc9a1243 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_enums.py @@ -0,0 +1,60 @@ +# 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 enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access rights of an authorization.""" + + MANAGE = "Manage" + SEND = "Send" + LISTEN = "Listen" + + +class EntityAvailabilityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Availability status of the entity.""" + + AVAILABLE = "Available" + LIMITED = "Limited" + RENAMING = "Renaming" + RESTORING = "Restoring" + UNKNOWN = "Unknown" + + +class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of a Service Bus resource.""" + + ACTIVE = "Active" + CREATING = "Creating" + DELETING = "Deleting" + DISABLED = "Disabled" + RECEIVE_DISABLED = "ReceiveDisabled" + RENAMING = "Renaming" + RESTORING = "Restoring" + SEND_DISABLED = "SendDisabled" + UNKNOWN = "Unknown" + + +class MessagingSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU for the messaging entity.""" + + BASIC = "Basic" + STANDARD = "Standard" + PREMIUM = "Premium" + + +class NamespaceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """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/models/_models.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_models.py index 578ba06fcc35..056e3a5fd044 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 @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -6,97 +7,187 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from azure.core.exceptions import HttpResponseError -import msrest.serialization +import datetime +import sys +from typing import Any, List, Optional, TYPE_CHECKING, Union +from .. import _serialization -class AuthorizationRule(msrest.serialization.Model): +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object + + +class AuthorizationRule(_serialization.Model): """Authorization rule of an entity. - :param type: The authorization type. - :type type: str - :param claim_type: The claim type. - :type claim_type: str - :param claim_value: The claim value. - :type claim_value: str - :param rights: Access rights of the entity. Values are 'Send', 'Listen', or 'Manage'. - :type rights: list[str or ~azure.servicebus.management._generated.models.AccessRights] - :param created_time: The date and time when the authorization rule was created. - :type created_time: ~datetime.datetime - :param modified_time: The date and time when the authorization rule was modified. - :type modified_time: ~datetime.datetime - :param key_name: The authorization rule key name. - :type key_name: str - :param primary_key: The primary key of the authorization rule. - :type primary_key: str - :param secondary_key: The primary key of the authorization rule. - :type secondary_key: str + :ivar type: The authorization type. + :vartype type: str + :ivar claim_type: The claim type. + :vartype claim_type: str + :ivar claim_value: The claim value. + :vartype claim_value: str + :ivar rights: Access rights of the entity. Values are 'Send', 'Listen', or 'Manage'. + :vartype rights: str or ~azure.servicebus.management._generated.models.AccessRights + :ivar created_time: The date and time when the authorization rule was created. + :vartype created_time: ~datetime.datetime + :ivar modified_time: The date and time when the authorization rule was modified. + :vartype modified_time: ~datetime.datetime + :ivar key_name: The authorization rule key name. + :vartype key_name: str + :ivar primary_key: The primary key of the authorization rule. + :vartype primary_key: str + :ivar secondary_key: The primary key of the authorization rule. + :vartype secondary_key: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'i', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, - 'claim_type': {'key': 'claimType', 'type': 'str', 'xml': {'name': 'ClaimType', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'claim_value': {'key': 'claimValue', 'type': 'str', 'xml': {'name': 'ClaimValue', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'rights': {'key': 'rights', 'type': '[str]', 'xml': {'name': 'Rights', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'AccessRights', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601', 'xml': {'name': 'CreatedTime', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'modified_time': {'key': 'modifiedTime', 'type': 'iso-8601', 'xml': {'name': 'ModifiedTime', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'key_name': {'key': 'keyName', 'type': 'str', 'xml': {'name': 'KeyName', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'primary_key': {'key': 'primaryKey', 'type': 'str', 'xml': {'name': 'PrimaryKey', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str', 'xml': {'name': 'SecondaryKey', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + "type": { + "key": "type", + "type": "str", + "xml": {"attr": True, "prefix": "i", "ns": "http://www.w3.org/2001/XMLSchema-instance"}, + }, + "claim_type": { + "key": "claimType", + "type": "str", + "xml": {"name": "ClaimType", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "claim_value": { + "key": "claimValue", + "type": "str", + "xml": {"name": "ClaimValue", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "rights": { + "key": "rights", + "type": "[str]", + "xml": { + "name": "Rights", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + "wrapped": True, + "itemsName": "AccessRights", + "itemsNs": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "created_time": { + "key": "createdTime", + "type": "iso-8601", + "xml": {"name": "CreatedTime", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "modified_time": { + "key": "modifiedTime", + "type": "iso-8601", + "xml": { + "name": "ModifiedTime", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "key_name": { + "key": "keyName", + "type": "str", + "xml": {"name": "KeyName", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "primary_key": { + "key": "primaryKey", + "type": "str", + "xml": {"name": "PrimaryKey", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "secondary_key": { + "key": "secondaryKey", + "type": "str", + "xml": { + "name": "SecondaryKey", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, } _xml_map = { - 'name': 'AuthorizationRule', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' + "name": "AuthorizationRule", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", } def __init__( self, - **kwargs - ): - super(AuthorizationRule, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.claim_type = kwargs.get('claim_type', None) - self.claim_value = kwargs.get('claim_value', None) - self.rights = kwargs.get('rights', None) - self.created_time = kwargs.get('created_time', None) - self.modified_time = kwargs.get('modified_time', None) - self.key_name = kwargs.get('key_name', None) - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - - -class RuleFilter(msrest.serialization.Model): + *, + type: Optional[str] = None, + claim_type: Optional[str] = None, + claim_value: Optional[str] = None, + rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, + created_time: Optional[datetime.datetime] = None, + modified_time: Optional[datetime.datetime] = None, + key_name: Optional[str] = None, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: The authorization type. + :paramtype type: str + :keyword claim_type: The claim type. + :paramtype claim_type: str + :keyword claim_value: The claim value. + :paramtype claim_value: str + :keyword rights: Access rights of the entity. Values are 'Send', 'Listen', or 'Manage'. + :paramtype rights: str or ~azure.servicebus.management._generated.models.AccessRights + :keyword created_time: The date and time when the authorization rule was created. + :paramtype created_time: ~datetime.datetime + :keyword modified_time: The date and time when the authorization rule was modified. + :paramtype modified_time: ~datetime.datetime + :keyword key_name: The authorization rule key name. + :paramtype key_name: str + :keyword primary_key: The primary key of the authorization rule. + :paramtype primary_key: str + :keyword secondary_key: The primary key of the authorization rule. + :paramtype secondary_key: str + """ + super().__init__(**kwargs) + self.type = type + self.claim_type = claim_type + self.claim_value = claim_value + self.rights = rights + self.created_time = created_time + self.modified_time = modified_time + self.key_name = key_name + self.primary_key = primary_key + self.secondary_key = secondary_key + + +class RuleFilter(_serialization.Model): """RuleFilter. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: CorrelationFilter, SqlFilter. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + CorrelationFilter, SqlFilter All required parameters must be populated in order to send to Azure. - :param type: Required. Constant filled by server. - :type type: str + :ivar type: Required. + :vartype type: str """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + "type": { + "key": "type", + "type": "str", + "xml": {"attr": True, "prefix": "xsi", "ns": "http://www.w3.org/2001/XMLSchema-instance"}, + }, } - _subtype_map = { - 'type': {'CorrelationFilter': 'CorrelationFilter', 'SqlFilter': 'SqlFilter'} - } - _xml_map = { - 'name': 'Filter', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' - } + _subtype_map = {"type": {"CorrelationFilter": "CorrelationFilter", "SqlFilter": "SqlFilter"}} + _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 + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type: Optional[str] = None class CorrelationFilter(RuleFilter): @@ -104,288 +195,394 @@ class CorrelationFilter(RuleFilter): All required parameters must be populated in order to send to Azure. - :param type: Required. 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] + :ivar type: Required. + :vartype type: str + :ivar correlation_id: + :vartype correlation_id: str + :ivar message_id: + :vartype message_id: str + :ivar to: + :vartype to: str + :ivar reply_to: + :vartype reply_to: str + :ivar label: + :vartype label: str + :ivar session_id: + :vartype session_id: str + :ivar reply_to_session_id: + :vartype reply_to_session_id: str + :ivar content_type: + :vartype content_type: str + :ivar properties: + :vartype properties: ~azure.servicebus.management._generated.models.KeyValue """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _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': {'name': 'CorrelationId', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'message_id': {'key': 'messageId', 'type': 'str', 'xml': {'name': 'MessageId', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'to': {'key': 'to', 'type': 'str', 'xml': {'name': 'To', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'reply_to': {'key': 'replyTo', 'type': 'str', 'xml': {'name': 'ReplyTo', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'label': {'key': 'label', 'type': 'str', 'xml': {'name': 'Label', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'session_id': {'key': 'sessionId', 'type': 'str', 'xml': {'name': 'SessionId', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'reply_to_session_id': {'key': 'replyToSessionId', 'type': 'str', 'xml': {'name': 'ReplyToSessionId', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'content_type': {'key': 'contentType', 'type': 'str', 'xml': {'name': 'ContentType', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'properties': {'key': 'properties', 'type': '[KeyValue]', 'xml': {'name': 'Properties', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'KeyValueOfstringanyType', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + "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": { + "name": "CorrelationId", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "message_id": { + "key": "messageId", + "type": "str", + "xml": {"name": "MessageId", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "to": { + "key": "to", + "type": "str", + "xml": {"name": "To", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "reply_to": { + "key": "replyTo", + "type": "str", + "xml": {"name": "ReplyTo", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "label": { + "key": "label", + "type": "str", + "xml": {"name": "Label", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "session_id": { + "key": "sessionId", + "type": "str", + "xml": {"name": "SessionId", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "reply_to_session_id": { + "key": "replyToSessionId", + "type": "str", + "xml": { + "name": "ReplyToSessionId", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "content_type": { + "key": "contentType", + "type": "str", + "xml": {"name": "ContentType", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "properties": { + "key": "properties", + "type": "[KeyValue]", + "xml": { + "name": "Properties", + "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): + *, + 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["_models.KeyValue"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword correlation_id: + :paramtype correlation_id: str + :keyword message_id: + :paramtype message_id: str + :keyword to: + :paramtype to: str + :keyword reply_to: + :paramtype reply_to: str + :keyword label: + :paramtype label: str + :keyword session_id: + :paramtype session_id: str + :keyword reply_to_session_id: + :paramtype reply_to_session_id: str + :keyword content_type: + :paramtype content_type: str + :keyword properties: + :paramtype properties: ~azure.servicebus.management._generated.models.KeyValue + """ + super().__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(_serialization.Model): """The request body for creating a queue. - :param content: QueueDescription for the new queue. - :type content: ~azure.servicebus.management._generated.models.CreateQueueBodyContent + :ivar content: QueueDescription for the new queue. + :vartype content: ~azure.servicebus.management._generated.models.CreateQueueBodyContent """ _attribute_map = { - 'content': {'key': 'content', 'type': 'CreateQueueBodyContent'}, - } - _xml_map = { - 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' + "content": {"key": "content", "type": "CreateQueueBodyContent"}, } + _xml_map = {"name": "entry", "ns": "http://www.w3.org/2005/Atom"} - def __init__( - self, - **kwargs - ): - super(CreateQueueBody, self).__init__(**kwargs) - self.content = kwargs.get('content', None) + def __init__(self, *, content: Optional["_models.CreateQueueBodyContent"] = None, **kwargs: Any) -> None: + """ + :keyword content: QueueDescription for the new queue. + :paramtype content: ~azure.servicebus.management._generated.models.CreateQueueBodyContent + """ + super().__init__(**kwargs) + self.content = content -class CreateQueueBodyContent(msrest.serialization.Model): +class CreateQueueBodyContent(_serialization.Model): """QueueDescription for the new queue. - :param type: MIME type of content. - :type type: str - :param queue_description: Properties of the new queue. - :type queue_description: ~azure.servicebus.management._generated.models.QueueDescription + :ivar type: MIME type of content. + :vartype type: str + :ivar queue_description: Properties of the new queue. + :vartype 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' + "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(CreateQueueBodyContent, self).__init__(**kwargs) - self.type = kwargs.get('type', "application/xml") - self.queue_description = kwargs.get('queue_description', None) - - -class CreateRuleBody(msrest.serialization.Model): + *, + type: str = "application/xml", + queue_description: Optional["_models.QueueDescription"] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: MIME type of content. + :paramtype type: str + :keyword queue_description: Properties of the new queue. + :paramtype queue_description: ~azure.servicebus.management._generated.models.QueueDescription + """ + super().__init__(**kwargs) + self.type = type + self.queue_description = queue_description + + +class CreateRuleBody(_serialization.Model): """The request body for creating a rule. - :param content: RuleDescription for the new Rule. - :type content: ~azure.servicebus.management._generated.models.CreateRuleBodyContent + :ivar content: RuleDescription for the new Rule. + :vartype 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' + "content": {"key": "content", "type": "CreateRuleBodyContent"}, } + _xml_map = {"name": "entry", "ns": "http://www.w3.org/2005/Atom"} - def __init__( - self, - **kwargs - ): - super(CreateRuleBody, self).__init__(**kwargs) - self.content = kwargs.get('content', None) + def __init__(self, *, content: Optional["_models.CreateRuleBodyContent"] = None, **kwargs: Any) -> None: + """ + :keyword content: RuleDescription for the new Rule. + :paramtype content: ~azure.servicebus.management._generated.models.CreateRuleBodyContent + """ + super().__init__(**kwargs) + self.content = content -class CreateRuleBodyContent(msrest.serialization.Model): +class CreateRuleBodyContent(_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 + :ivar type: MIME type of content. + :vartype type: str + :ivar rule_description: Rule information to create. + :vartype 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' + "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(CreateRuleBodyContent, self).__init__(**kwargs) - self.type = kwargs.get('type', "application/xml") - self.rule_description = kwargs.get('rule_description', None) - - -class CreateSubscriptionBody(msrest.serialization.Model): + *, + type: str = "application/xml", + rule_description: Optional["_models.RuleDescription"] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: MIME type of content. + :paramtype type: str + :keyword rule_description: Rule information to create. + :paramtype rule_description: ~azure.servicebus.management._generated.models.RuleDescription + """ + super().__init__(**kwargs) + self.type = type + self.rule_description = rule_description + + +class CreateSubscriptionBody(_serialization.Model): """The request body for creating a subscription. - :param content: SubscriptionDescription for the new subscription. - :type content: ~azure.servicebus.management._generated.models.CreateSubscriptionBodyContent + :ivar content: SubscriptionDescription for the new subscription. + :vartype 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' + "content": {"key": "content", "type": "CreateSubscriptionBodyContent"}, } + _xml_map = {"name": "entry", "ns": "http://www.w3.org/2005/Atom"} - def __init__( - self, - **kwargs - ): - super(CreateSubscriptionBody, self).__init__(**kwargs) - self.content = kwargs.get('content', None) + def __init__(self, *, content: Optional["_models.CreateSubscriptionBodyContent"] = None, **kwargs: Any) -> None: + """ + :keyword content: SubscriptionDescription for the new subscription. + :paramtype content: + ~azure.servicebus.management._generated.models.CreateSubscriptionBodyContent + """ + super().__init__(**kwargs) + self.content = content -class CreateSubscriptionBodyContent(msrest.serialization.Model): +class CreateSubscriptionBodyContent(_serialization.Model): """SubscriptionDescription for the new subscription. - :param type: MIME type of content. - :type type: str - :param subscription_description: Subscription information to create. - :type subscription_description: + :ivar type: MIME type of content. + :vartype type: str + :ivar subscription_description: Subscription information to create. + :vartype 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' + "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(CreateSubscriptionBodyContent, self).__init__(**kwargs) - self.type = kwargs.get('type', "application/xml") - self.subscription_description = kwargs.get('subscription_description', None) - - -class CreateTopicBody(msrest.serialization.Model): + *, + type: str = "application/xml", + subscription_description: Optional["_models.SubscriptionDescription"] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: MIME type of content. + :paramtype type: str + :keyword subscription_description: Subscription information to create. + :paramtype subscription_description: + ~azure.servicebus.management._generated.models.SubscriptionDescription + """ + super().__init__(**kwargs) + self.type = type + self.subscription_description = subscription_description + + +class CreateTopicBody(_serialization.Model): """The request body for creating a topic. - :param content: TopicDescription for the new topic. - :type content: ~azure.servicebus.management._generated.models.CreateTopicBodyContent + :ivar content: TopicDescription for the new topic. + :vartype content: ~azure.servicebus.management._generated.models.CreateTopicBodyContent """ _attribute_map = { - 'content': {'key': 'content', 'type': 'CreateTopicBodyContent'}, - } - _xml_map = { - 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' + "content": {"key": "content", "type": "CreateTopicBodyContent"}, } + _xml_map = {"name": "entry", "ns": "http://www.w3.org/2005/Atom"} - def __init__( - self, - **kwargs - ): - super(CreateTopicBody, self).__init__(**kwargs) - self.content = kwargs.get('content', None) + def __init__(self, *, content: Optional["_models.CreateTopicBodyContent"] = None, **kwargs: Any) -> None: + """ + :keyword content: TopicDescription for the new topic. + :paramtype content: ~azure.servicebus.management._generated.models.CreateTopicBodyContent + """ + super().__init__(**kwargs) + self.content = content -class CreateTopicBodyContent(msrest.serialization.Model): +class CreateTopicBodyContent(_serialization.Model): """TopicDescription for the new topic. - :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 + :ivar type: MIME type of content. + :vartype type: str + :ivar topic_description: Topic information to create. + :vartype 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' + "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(CreateTopicBodyContent, self).__init__(**kwargs) - self.type = kwargs.get('type', "application/xml") - self.topic_description = kwargs.get('topic_description', None) - - -class RuleAction(msrest.serialization.Model): + *, + type: str = "application/xml", + topic_description: Optional["_models.TopicDescription"] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: MIME type of content. + :paramtype type: str + :keyword topic_description: Topic information to create. + :paramtype topic_description: ~azure.servicebus.management._generated.models.TopicDescription + """ + super().__init__(**kwargs) + self.type = type + self.topic_description = topic_description + + +class RuleAction(_serialization.Model): """RuleAction. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: EmptyRuleAction, SqlRuleAction. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + EmptyRuleAction, SqlRuleAction All required parameters must be populated in order to send to Azure. - :param type: Required. Constant filled by server. - :type type: str + :ivar type: Required. + :vartype type: str """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + "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' - } + _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 = None + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type: Optional[str] = None class EmptyRuleAction(RuleAction): @@ -393,72 +590,122 @@ class EmptyRuleAction(RuleAction): All required parameters must be populated in order to send to Azure. - :param type: Required. Constant filled by server. - :type type: str + :ivar type: Required. + :vartype type: str """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'xsi', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, + "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 = 'EmptyRuleAction' + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type: str = "EmptyRuleAction" class SqlFilter(RuleFilter): """SqlFilter. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FalseFilter, TrueFilter. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FalseFilter, TrueFilter All required parameters must be populated in order to send to Azure. - :param type: Required. Constant filled by server. - :type type: str - :param sql_expression: - :type sql_expression: str - :param compatibility_level: - :type compatibility_level: str - :param parameters: - :type parameters: list[~azure.servicebus.management._generated.models.KeyValue] - :param requires_preprocessing: - :type requires_preprocessing: bool + :ivar type: Required. + :vartype type: str + :ivar sql_expression: + :vartype sql_expression: str + :ivar compatibility_level: + :vartype compatibility_level: str + :ivar parameters: + :vartype parameters: ~azure.servicebus.management._generated.models.KeyValue + :ivar requires_preprocessing: + :vartype requires_preprocessing: bool """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _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': {'name': 'SqlExpression', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'str', 'xml': {'name': 'CompatibilityLevel', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'parameters': {'key': 'parameters', 'type': '[KeyValue]', 'xml': {'name': 'Parameters', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'KeyValueOfstringanyType', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool', 'xml': {'name': 'RequiresPreprocessing', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - } - - _subtype_map = { - 'type': {'FalseFilter': 'FalseFilter', 'TrueFilter': 'TrueFilter'} - } + "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": { + "name": "SqlExpression", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "compatibility_level": { + "key": "compatibilityLevel", + "type": "str", + "xml": { + "name": "CompatibilityLevel", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "parameters": { + "key": "parameters", + "type": "[KeyValue]", + "xml": { + "name": "Parameters", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + "wrapped": True, + "itemsName": "KeyValueOfstringanyType", + "itemsNs": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "requires_preprocessing": { + "key": "requiresPreprocessing", + "type": "bool", + "xml": { + "name": "RequiresPreprocessing", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + } + + _subtype_map = {"type": {"FalseFilter": "FalseFilter", "TrueFilter": "TrueFilter"}} def __init__( self, - **kwargs - ): - super(SqlFilter, self).__init__(**kwargs) - self.type = 'SqlFilter' - self.sql_expression = kwargs.get('sql_expression', None) - self.compatibility_level = kwargs.get('compatibility_level', "20") - self.parameters = kwargs.get('parameters', None) - self.requires_preprocessing = kwargs.get('requires_preprocessing', None) + *, + sql_expression: Optional[str] = None, + compatibility_level: str = "20", + parameters: Optional[List["_models.KeyValue"]] = None, + requires_preprocessing: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword sql_expression: + :paramtype sql_expression: str + :keyword compatibility_level: + :paramtype compatibility_level: str + :keyword parameters: + :paramtype parameters: ~azure.servicebus.management._generated.models.KeyValue + :keyword requires_preprocessing: + :paramtype requires_preprocessing: bool + """ + super().__init__(**kwargs) + self.type: str = "SqlFilter" + self.sql_expression = sql_expression + self.compatibility_level = compatibility_level + self.parameters = parameters + self.requires_preprocessing = requires_preprocessing class FalseFilter(SqlFilter): @@ -466,692 +713,1328 @@ class FalseFilter(SqlFilter): All required parameters must be populated in order to send to Azure. - :param type: Required. Constant filled by server. - :type type: str - :param sql_expression: - :type sql_expression: str - :param compatibility_level: - :type compatibility_level: str - :param parameters: - :type parameters: list[~azure.servicebus.management._generated.models.KeyValue] - :param requires_preprocessing: - :type requires_preprocessing: bool + :ivar type: Required. + :vartype type: str + :ivar sql_expression: + :vartype sql_expression: str + :ivar compatibility_level: + :vartype compatibility_level: str + :ivar parameters: + :vartype parameters: ~azure.servicebus.management._generated.models.KeyValue + :ivar requires_preprocessing: + :vartype requires_preprocessing: bool """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _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': {'name': 'SqlExpression', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'str', 'xml': {'name': 'CompatibilityLevel', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'parameters': {'key': 'parameters', 'type': '[KeyValue]', 'xml': {'name': 'Parameters', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'KeyValueOfstringanyType', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool', 'xml': {'name': 'RequiresPreprocessing', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + "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": { + "name": "SqlExpression", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "compatibility_level": { + "key": "compatibilityLevel", + "type": "str", + "xml": { + "name": "CompatibilityLevel", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "parameters": { + "key": "parameters", + "type": "[KeyValue]", + "xml": { + "name": "Parameters", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + "wrapped": True, + "itemsName": "KeyValueOfstringanyType", + "itemsNs": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "requires_preprocessing": { + "key": "requiresPreprocessing", + "type": "bool", + "xml": { + "name": "RequiresPreprocessing", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, } def __init__( self, - **kwargs - ): - super(FalseFilter, self).__init__(**kwargs) - self.type = 'FalseFilter' - - -class KeyValue(msrest.serialization.Model): + *, + sql_expression: Optional[str] = None, + compatibility_level: str = "20", + parameters: Optional[List["_models.KeyValue"]] = None, + requires_preprocessing: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword sql_expression: + :paramtype sql_expression: str + :keyword compatibility_level: + :paramtype compatibility_level: str + :keyword parameters: + :paramtype parameters: ~azure.servicebus.management._generated.models.KeyValue + :keyword requires_preprocessing: + :paramtype requires_preprocessing: bool + """ + super().__init__( + sql_expression=sql_expression, + compatibility_level=compatibility_level, + parameters=parameters, + requires_preprocessing=requires_preprocessing, + **kwargs + ) + self.type: str = "FalseFilter" + + +class KeyValue(_serialization.Model): """Key Values of custom properties. - :param key: - :type key: str - :param value: - :type value: str + :ivar key: + :vartype key: str + :ivar value: + :vartype value: str """ _attribute_map = { - 'key': {'key': 'key', 'type': 'str', 'xml': {'name': 'Key', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'value': {'key': 'value', 'type': 'str', 'xml': {'name': 'Value', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + "key": { + "key": "key", + "type": "str", + "xml": {"name": "Key", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "value": { + "key": "value", + "type": "str", + "xml": {"name": "Value", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, } _xml_map = { - 'name': 'KeyValueOfstringanyType', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' + "name": "KeyValueOfstringanyType", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", } - def __init__( - self, - **kwargs - ): - super(KeyValue, self).__init__(**kwargs) - self.key = kwargs.get('key', None) - self.value = kwargs.get('value', None) + def __init__(self, *, key: Optional[str] = None, value: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword key: + :paramtype key: str + :keyword value: + :paramtype value: str + """ + super().__init__(**kwargs) + self.key = key + self.value = value -class MessageCountDetails(msrest.serialization.Model): +class MessageCountDetails(_serialization.Model): """Details about the message counts in entity. - :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 + :ivar active_message_count: Number of active messages in the queue, topic, or subscription. + :vartype active_message_count: int + :ivar dead_letter_message_count: Number of messages that are dead lettered. + :vartype dead_letter_message_count: int + :ivar scheduled_message_count: Number of scheduled messages. + :vartype scheduled_message_count: int + :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. + :vartype transfer_dead_letter_message_count: int + :ivar transfer_message_count: Number of messages transferred to another queue, topic, or subscription. - :type transfer_message_count: int + :vartype transfer_message_count: int """ _attribute_map = { - 'active_message_count': {'key': 'activeMessageCount', 'type': 'int', 'xml': {'name': 'ActiveMessageCount', 'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, - 'dead_letter_message_count': {'key': 'deadLetterMessageCount', 'type': 'int', 'xml': {'name': 'DeadLetterMessageCount', 'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, - 'scheduled_message_count': {'key': 'scheduledMessageCount', 'type': 'int', 'xml': {'name': 'ScheduledMessageCount', 'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, - 'transfer_dead_letter_message_count': {'key': 'transferDeadLetterMessageCount', 'type': 'int', 'xml': {'name': 'TransferDeadLetterMessageCount', 'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, - 'transfer_message_count': {'key': 'transferMessageCount', 'type': 'int', 'xml': {'name': 'TransferMessageCount', 'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, - } - _xml_map = { - 'name': 'CountDetails', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' - } + "active_message_count": { + "key": "activeMessageCount", + "type": "int", + "xml": { + "name": "ActiveMessageCount", + "prefix": "d2p1", + "ns": "http://schemas.microsoft.com/netservices/2011/06/servicebus", + }, + }, + "dead_letter_message_count": { + "key": "deadLetterMessageCount", + "type": "int", + "xml": { + "name": "DeadLetterMessageCount", + "prefix": "d2p1", + "ns": "http://schemas.microsoft.com/netservices/2011/06/servicebus", + }, + }, + "scheduled_message_count": { + "key": "scheduledMessageCount", + "type": "int", + "xml": { + "name": "ScheduledMessageCount", + "prefix": "d2p1", + "ns": "http://schemas.microsoft.com/netservices/2011/06/servicebus", + }, + }, + "transfer_dead_letter_message_count": { + "key": "transferDeadLetterMessageCount", + "type": "int", + "xml": { + "name": "TransferDeadLetterMessageCount", + "prefix": "d2p1", + "ns": "http://schemas.microsoft.com/netservices/2011/06/servicebus", + }, + }, + "transfer_message_count": { + "key": "transferMessageCount", + "type": "int", + "xml": { + "name": "TransferMessageCount", + "prefix": "d2p1", + "ns": "http://schemas.microsoft.com/netservices/2011/06/servicebus", + }, + }, + } + _xml_map = {"name": "CountDetails", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"} 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) - - -class NamespaceProperties(msrest.serialization.Model): + *, + active_message_count: Optional[int] = None, + dead_letter_message_count: Optional[int] = None, + scheduled_message_count: Optional[int] = None, + transfer_dead_letter_message_count: Optional[int] = None, + transfer_message_count: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword active_message_count: Number of active messages in the queue, topic, or subscription. + :paramtype active_message_count: int + :keyword dead_letter_message_count: Number of messages that are dead lettered. + :paramtype dead_letter_message_count: int + :keyword scheduled_message_count: Number of scheduled messages. + :paramtype scheduled_message_count: int + :keyword transfer_dead_letter_message_count: Number of messages transferred into dead letters. + :paramtype transfer_dead_letter_message_count: int + :keyword transfer_message_count: Number of messages transferred to another queue, topic, or + subscription. + :paramtype transfer_message_count: int + """ + super().__init__(**kwargs) + self.active_message_count = active_message_count + self.dead_letter_message_count = dead_letter_message_count + self.scheduled_message_count = scheduled_message_count + self.transfer_dead_letter_message_count = transfer_dead_letter_message_count + self.transfer_message_count = transfer_message_count + + +class NamespaceProperties(_serialization.Model): """The metadata related to a Service Bus namespace. - :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 + :ivar alias: Alias for the geo-disaster recovery Service Bus namespace. + :vartype alias: str + :ivar created_time: The exact time the namespace was created. + :vartype created_time: ~datetime.datetime + :ivar messaging_sku: The SKU for the messaging entity. Known values are: "Basic", "Standard", + and "Premium". + :vartype messaging_sku: str or ~azure.servicebus.management._generated.models.MessagingSku + :ivar messaging_units: The number of messaging units allocated to the namespace. + :vartype messaging_units: int + :ivar modified_time: The exact time the namespace was last modified. + :vartype modified_time: ~datetime.datetime + :ivar name: Name of the namespace. + :vartype name: str + :ivar namespace_type: The type of entities the namespace can contain. Known values are: + "Messaging", "NotificationHub", "Mixed", "EventHub", and "Relay". + :vartype namespace_type: str or ~azure.servicebus.management._generated.models.NamespaceType """ _attribute_map = { - 'alias': {'key': 'alias', 'type': 'str', 'xml': {'name': 'Alias', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601', 'xml': {'name': 'CreatedTime', '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': {'name': 'MessagingUnits', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'modified_time': {'key': 'modifiedTime', 'type': 'iso-8601', 'xml': {'name': 'ModifiedTime', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'name': {'key': 'name', 'type': 'str', 'xml': {'name': 'Name', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'namespace_type': {'key': 'namespaceType', 'type': 'str', 'xml': {'name': 'NamespaceType', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - } - _xml_map = { - 'name': 'NamespaceInfo', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' - } + "alias": { + "key": "alias", + "type": "str", + "xml": {"name": "Alias", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "created_time": { + "key": "createdTime", + "type": "iso-8601", + "xml": {"name": "CreatedTime", "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": { + "name": "MessagingUnits", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "modified_time": { + "key": "modifiedTime", + "type": "iso-8601", + "xml": { + "name": "ModifiedTime", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "name": { + "key": "name", + "type": "str", + "xml": {"name": "Name", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "namespace_type": { + "key": "namespaceType", + "type": "str", + "xml": { + "name": "NamespaceType", + "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(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): + *, + alias: Optional[str] = None, + created_time: Optional[datetime.datetime] = None, + messaging_sku: Optional[Union[str, "_models.MessagingSku"]] = None, + messaging_units: Optional[int] = None, + modified_time: Optional[datetime.datetime] = None, + name: Optional[str] = None, + namespace_type: Optional[Union[str, "_models.NamespaceType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword alias: Alias for the geo-disaster recovery Service Bus namespace. + :paramtype alias: str + :keyword created_time: The exact time the namespace was created. + :paramtype created_time: ~datetime.datetime + :keyword messaging_sku: The SKU for the messaging entity. Known values are: "Basic", + "Standard", and "Premium". + :paramtype messaging_sku: str or ~azure.servicebus.management._generated.models.MessagingSku + :keyword messaging_units: The number of messaging units allocated to the namespace. + :paramtype messaging_units: int + :keyword modified_time: The exact time the namespace was last modified. + :paramtype modified_time: ~datetime.datetime + :keyword name: Name of the namespace. + :paramtype name: str + :keyword namespace_type: The type of entities the namespace can contain. Known values are: + "Messaging", "NotificationHub", "Mixed", "EventHub", and "Relay". + :paramtype namespace_type: str or ~azure.servicebus.management._generated.models.NamespaceType + """ + super().__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(_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 + All required parameters must be populated in order to send to Azure. + + :ivar id: The URL of the GET request. + :vartype id: str + :ivar title: The name of the namespace. Required. + :vartype title: str + :ivar updated: The timestamp for when this namespace was last updated. + :vartype updated: ~datetime.datetime + :ivar author: The author that created this resource. + :vartype author: ~azure.servicebus.management._generated.models.ResponseAuthor + :ivar link: The URL for the HTTP request. + :vartype link: ~azure.servicebus.management._generated.models.ResponseLink + :ivar content: Information about the namespace. + :vartype 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'}, + _validation = { + "title": {"required": True}, } - _xml_map = { - 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' + + _attribute_map = { + "id": {"key": "id", "type": "str", "xml": {"ns": "http://www.w3.org/2005/Atom"}}, + "title": {"key": "title", "type": "str", "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": "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 NamespacePropertiesEntryContent(msrest.serialization.Model): + *, + title: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + updated: Optional[datetime.datetime] = None, + author: Optional["_models.ResponseAuthor"] = None, + link: Optional["_models.ResponseLink"] = None, + content: Optional["_models.NamespacePropertiesEntryContent"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The URL of the GET request. + :paramtype id: str + :keyword title: The name of the namespace. Required. + :paramtype title: str + :keyword updated: The timestamp for when this namespace was last updated. + :paramtype updated: ~datetime.datetime + :keyword author: The author that created this resource. + :paramtype author: ~azure.servicebus.management._generated.models.ResponseAuthor + :keyword link: The URL for the HTTP request. + :paramtype link: ~azure.servicebus.management._generated.models.ResponseLink + :keyword content: Information about the namespace. + :paramtype content: + ~azure.servicebus.management._generated.models.NamespacePropertiesEntryContent + """ + super().__init__(**kwargs) + self.id = id + self.title = title + self.updated = updated + self.author = author + self.link = link + self.content = content + + +class NamespacePropertiesEntryContent(_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 + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of content in namespace info response. Required. + :vartype type: str + :ivar namespace_properties: The metadata related to a Service Bus namespace. Required. + :vartype namespace_properties: + ~azure.servicebus.management._generated.models.NamespaceProperties """ - _attribute_map = { - 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, - 'namespace_properties': {'key': 'NamespaceProperties', 'type': 'NamespaceProperties'}, + _validation = { + "type": {"required": True}, + "namespace_properties": {"required": True}, } - _xml_map = { - 'ns': 'http://www.w3.org/2005/Atom' + + _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, - **kwargs - ): - super(NamespacePropertiesEntryContent, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.namespace_properties = kwargs.get('namespace_properties', None) + def __init__(self, *, type: str, namespace_properties: "_models.NamespaceProperties", **kwargs: Any) -> None: + """ + :keyword type: Type of content in namespace info response. Required. + :paramtype type: str + :keyword namespace_properties: The metadata related to a Service Bus namespace. Required. + :paramtype namespace_properties: + ~azure.servicebus.management._generated.models.NamespaceProperties + """ + super().__init__(**kwargs) + self.type = type + self.namespace_properties = namespace_properties -class QueueDescription(msrest.serialization.Model): +class QueueDescription(_serialization.Model): # pylint: disable=too-many-instance-attributes """Description of a Service Bus queue resource. - :param lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time + :ivar 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 + :vartype lock_duration: ~datetime.timedelta + :ivar 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: long - :param requires_duplicate_detection: A value indicating if this queue requires duplicate + :vartype max_size_in_megabytes: int + :ivar 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 + :vartype requires_duplicate_detection: bool + :ivar 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 + :vartype requires_session: bool + :ivar 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 + :vartype default_message_time_to_live: ~datetime.timedelta + :ivar 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 + :vartype dead_lettering_on_message_expiration: bool + :ivar 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 + :vartype duplicate_detection_history_time_window: ~datetime.timedelta + :ivar 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 + :vartype max_delivery_count: int + :ivar 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 + :vartype enable_batched_operations: bool + :ivar size_in_bytes: The size of the queue, in bytes. + :vartype size_in_bytes: int + :ivar message_count: The number of messages in the queue. + :vartype message_count: int + :ivar 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 forward_to: The name of the recipient entity to which all the messages sent to the queue + :vartype is_anonymous_accessible: bool + :ivar authorization_rules: Authorization rules for resource. + :vartype authorization_rules: ~azure.servicebus.management._generated.models.AuthorizationRule + :ivar status: Status of a Service Bus resource. Known values are: "Active", "Creating", + "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", and + "Unknown". + :vartype status: str or ~azure.servicebus.management._generated.models.EntityStatus + :ivar forward_to: The name of the recipient entity to which all the messages sent to the queue are forwarded to. - :type forward_to: str - :param user_metadata: Custom metdata that user can associate with the description. Max length + :vartype forward_to: str + :ivar user_metadata: Custom metadata that user can associate with the description. Max length is 1024 chars. - :type user_metadata: str - :param created_at: The exact time the queue was created. - :type created_at: ~datetime.datetime - :param updated_at: The exact time the entity description was last updated. - :type updated_at: ~datetime.datetime - :param accessed_at: Last time a message was sent, or the last time there was a receive request + :vartype user_metadata: str + :ivar created_at: The exact time the queue was created. + :vartype created_at: ~datetime.datetime + :ivar updated_at: The exact time the entity description was last updated. + :vartype updated_at: ~datetime.datetime + :ivar 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 entity. - :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 + :vartype accessed_at: ~datetime.datetime + :ivar support_ordering: Indicates if messages are received in the same order they are sent. For + queues, defaults to true and setting it to false has no effect. + :vartype support_ordering: bool + :ivar message_count_details: Details about the message counts in entity. + :vartype message_count_details: + ~azure.servicebus.management._generated.models.MessageCountDetails + :ivar 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 + :vartype auto_delete_on_idle: ~datetime.timedelta + :ivar enable_partitioning: A value that indicates whether the queue is to be partitioned across + multiple message brokers. + :vartype enable_partitioning: bool + :ivar entity_availability_status: Availability status of the entity. Known values are: + "Available", "Limited", "Renaming", "Restoring", and "Unknown". + :vartype 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 + :ivar 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 forward_dead_lettered_messages_to: The name of the recipient entity to which all the + :vartype enable_express: bool + :ivar forward_dead_lettered_messages_to: The name of the recipient entity to which all the dead-lettered messages of this subscription are forwarded to. - :type forward_dead_lettered_messages_to: str - :param max_message_size_in_kilobytes: The maximum size in kilobytes of message payload that can + :vartype forward_dead_lettered_messages_to: str + :ivar max_message_size_in_kilobytes: The maximum size in kilobytes of message payload that can be accepted by the queue. - :type max_message_size_in_kilobytes: int + :vartype max_message_size_in_kilobytes: int """ _attribute_map = { - 'lock_duration': {'key': 'lockDuration', 'type': 'duration', 'xml': {'name': 'LockDuration', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_size_in_megabytes': {'key': 'maxSizeInMegabytes', 'type': 'long', 'xml': {'name': 'MaxSizeInMegabytes', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_duplicate_detection': {'key': 'requiresDuplicateDetection', 'type': 'bool', 'xml': {'name': 'RequiresDuplicateDetection', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_session': {'key': 'requiresSession', 'type': 'bool', 'xml': {'name': 'RequiresSession', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'default_message_time_to_live': {'key': 'defaultMessageTimeToLive', 'type': 'duration', 'xml': {'name': 'DefaultMessageTimeToLive', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'dead_lettering_on_message_expiration': {'key': 'deadLetteringOnMessageExpiration', 'type': 'bool', 'xml': {'name': 'DeadLetteringOnMessageExpiration', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'duplicate_detection_history_time_window': {'key': 'duplicateDetectionHistoryTimeWindow', 'type': 'duration', 'xml': {'name': 'DuplicateDetectionHistoryTimeWindow', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int', 'xml': {'name': 'MaxDeliveryCount', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_batched_operations': {'key': 'enableBatchedOperations', 'type': 'bool', 'xml': {'name': 'EnableBatchedOperations', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'size_in_bytes': {'key': 'sizeInBytes', 'type': 'int', 'xml': {'name': 'SizeInBytes', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'message_count': {'key': 'messageCount', 'type': 'int', 'xml': {'name': 'MessageCount', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'is_anonymous_accessible': {'key': 'isAnonymousAccessible', 'type': 'bool', 'xml': {'name': 'IsAnonymousAccessible', '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': {'name': 'Status', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'forward_to': {'key': 'forwardTo', 'type': 'str', 'xml': {'name': 'ForwardTo', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'user_metadata': {'key': 'userMetadata', 'type': 'str', 'xml': {'name': 'UserMetadata', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601', 'xml': {'name': 'CreatedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'updated_at': {'key': 'updatedAt', 'type': 'iso-8601', 'xml': {'name': 'UpdatedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'accessed_at': {'key': 'accessedAt', 'type': 'iso-8601', 'xml': {'name': 'AccessedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'support_ordering': {'key': 'supportOrdering', 'type': 'bool', 'xml': {'name': 'SupportOrdering', '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': {'name': 'AutoDeleteOnIdle', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_partitioning': {'key': 'enablePartitioning', 'type': 'bool', 'xml': {'name': 'EnablePartitioning', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'entity_availability_status': {'key': 'entityAvailabilityStatus', 'type': 'str', 'xml': {'name': 'EntityAvailabilityStatus', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_express': {'key': 'enableExpress', 'type': 'bool', 'xml': {'name': 'EnableExpress', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'forward_dead_lettered_messages_to': {'key': 'forwardDeadLetteredMessagesTo', 'type': 'str', 'xml': {'name': 'ForwardDeadLetteredMessagesTo', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_message_size_in_kilobytes': {'key': 'maxMessageSizeInKilobytes', 'type': 'int', 'xml': {'name': 'MaxMessageSizeInKilobytes', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - } - _xml_map = { - 'name': 'QueueDescription', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' - } - - def __init__( + "lock_duration": { + "key": "lockDuration", + "type": "duration", + "xml": { + "name": "LockDuration", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "max_size_in_megabytes": { + "key": "maxSizeInMegabytes", + "type": "int", + "xml": { + "name": "MaxSizeInMegabytes", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "requires_duplicate_detection": { + "key": "requiresDuplicateDetection", + "type": "bool", + "xml": { + "name": "RequiresDuplicateDetection", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "requires_session": { + "key": "requiresSession", + "type": "bool", + "xml": { + "name": "RequiresSession", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "default_message_time_to_live": { + "key": "defaultMessageTimeToLive", + "type": "duration", + "xml": { + "name": "DefaultMessageTimeToLive", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "dead_lettering_on_message_expiration": { + "key": "deadLetteringOnMessageExpiration", + "type": "bool", + "xml": { + "name": "DeadLetteringOnMessageExpiration", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "duplicate_detection_history_time_window": { + "key": "duplicateDetectionHistoryTimeWindow", + "type": "duration", + "xml": { + "name": "DuplicateDetectionHistoryTimeWindow", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "max_delivery_count": { + "key": "maxDeliveryCount", + "type": "int", + "xml": { + "name": "MaxDeliveryCount", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "enable_batched_operations": { + "key": "enableBatchedOperations", + "type": "bool", + "xml": { + "name": "EnableBatchedOperations", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "size_in_bytes": { + "key": "sizeInBytes", + "type": "int", + "xml": {"name": "SizeInBytes", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "message_count": { + "key": "messageCount", + "type": "int", + "xml": { + "name": "MessageCount", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "is_anonymous_accessible": { + "key": "isAnonymousAccessible", + "type": "bool", + "xml": { + "name": "IsAnonymousAccessible", + "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": {"name": "Status", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "forward_to": { + "key": "forwardTo", + "type": "str", + "xml": {"name": "ForwardTo", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "user_metadata": { + "key": "userMetadata", + "type": "str", + "xml": { + "name": "UserMetadata", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "created_at": { + "key": "createdAt", + "type": "iso-8601", + "xml": {"name": "CreatedAt", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "updated_at": { + "key": "updatedAt", + "type": "iso-8601", + "xml": {"name": "UpdatedAt", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "accessed_at": { + "key": "accessedAt", + "type": "iso-8601", + "xml": {"name": "AccessedAt", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "support_ordering": { + "key": "supportOrdering", + "type": "bool", + "xml": { + "name": "SupportOrdering", + "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": { + "name": "AutoDeleteOnIdle", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "enable_partitioning": { + "key": "enablePartitioning", + "type": "bool", + "xml": { + "name": "EnablePartitioning", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "entity_availability_status": { + "key": "entityAvailabilityStatus", + "type": "str", + "xml": { + "name": "EntityAvailabilityStatus", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "enable_express": { + "key": "enableExpress", + "type": "bool", + "xml": { + "name": "EnableExpress", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "forward_dead_lettered_messages_to": { + "key": "forwardDeadLetteredMessagesTo", + "type": "str", + "xml": { + "name": "ForwardDeadLetteredMessagesTo", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "max_message_size_in_kilobytes": { + "key": "maxMessageSizeInKilobytes", + "type": "int", + "xml": { + "name": "MaxMessageSizeInKilobytes", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + } + _xml_map = {"name": "QueueDescription", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"} + + def __init__( # pylint: disable=too-many-locals self, - **kwargs - ): - 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.forward_to = kwargs.get('forward_to', None) - self.user_metadata = kwargs.get('user_metadata', 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) - self.forward_dead_lettered_messages_to = kwargs.get('forward_dead_lettered_messages_to', None) - self.max_message_size_in_kilobytes = kwargs.get('max_message_size_in_kilobytes', None) - - -class QueueDescriptionEntry(msrest.serialization.Model): + *, + lock_duration: Optional[datetime.timedelta] = None, + max_size_in_megabytes: Optional[int] = None, + requires_duplicate_detection: Optional[bool] = None, + requires_session: Optional[bool] = 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["_models.AuthorizationRule"]] = None, + status: Optional[Union[str, "_models.EntityStatus"]] = None, + forward_to: Optional[str] = None, + user_metadata: Optional[str] = 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["_models.MessageCountDetails"] = None, + auto_delete_on_idle: Optional[datetime.timedelta] = None, + enable_partitioning: Optional[bool] = None, + entity_availability_status: Optional[Union[str, "_models.EntityAvailabilityStatus"]] = None, + enable_express: Optional[bool] = None, + forward_dead_lettered_messages_to: Optional[str] = None, + max_message_size_in_kilobytes: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :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. + :paramtype lock_duration: ~datetime.timedelta + :keyword max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size + of memory allocated for the queue. + :paramtype max_size_in_megabytes: int + :keyword requires_duplicate_detection: A value indicating if this queue requires duplicate + detection. + :paramtype requires_duplicate_detection: bool + :keyword requires_session: A value that indicates whether the queue supports the concept of + sessions. + :paramtype 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. + :paramtype 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. + :paramtype dead_lettering_on_message_expiration: 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. + :paramtype duplicate_detection_history_time_window: ~datetime.timedelta + :keyword max_delivery_count: The maximum delivery count. A message is automatically + deadlettered after this number of deliveries. Default value is 10. + :paramtype max_delivery_count: int + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :paramtype enable_batched_operations: bool + :keyword size_in_bytes: The size of the queue, in bytes. + :paramtype size_in_bytes: int + :keyword message_count: The number of messages in the queue. + :paramtype message_count: int + :keyword is_anonymous_accessible: A value indicating if the resource can be accessed without + authorization. + :paramtype is_anonymous_accessible: bool + :keyword authorization_rules: Authorization rules for resource. + :paramtype authorization_rules: + ~azure.servicebus.management._generated.models.AuthorizationRule + :keyword status: Status of a Service Bus resource. Known values are: "Active", "Creating", + "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", and + "Unknown". + :paramtype status: str or ~azure.servicebus.management._generated.models.EntityStatus + :keyword forward_to: The name of the recipient entity to which all the messages sent to the + queue are forwarded to. + :paramtype forward_to: str + :keyword user_metadata: Custom metadata that user can associate with the description. Max + length is 1024 chars. + :paramtype user_metadata: str + :keyword created_at: The exact time the queue was created. + :paramtype created_at: ~datetime.datetime + :keyword updated_at: The exact time the entity description was last updated. + :paramtype 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. + :paramtype accessed_at: ~datetime.datetime + :keyword support_ordering: Indicates if messages are received in the same order they are sent. + For queues, defaults to true and setting it to false has no effect. + :paramtype support_ordering: bool + :keyword message_count_details: Details about the message counts in entity. + :paramtype message_count_details: + ~azure.servicebus.management._generated.models.MessageCountDetails + :keyword auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the queue is + automatically deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: ~datetime.timedelta + :keyword enable_partitioning: A value that indicates whether the queue is to be partitioned + across multiple message brokers. + :paramtype enable_partitioning: bool + :keyword entity_availability_status: Availability status of the entity. Known values are: + "Available", "Limited", "Renaming", "Restoring", and "Unknown". + :paramtype entity_availability_status: str or + ~azure.servicebus.management._generated.models.EntityAvailabilityStatus + :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. + :paramtype enable_express: bool + :keyword forward_dead_lettered_messages_to: The name of the recipient entity to which all the + dead-lettered messages of this subscription are forwarded to. + :paramtype forward_dead_lettered_messages_to: str + :keyword max_message_size_in_kilobytes: The maximum size in kilobytes of message payload that + can be accepted by the queue. + :paramtype max_message_size_in_kilobytes: int + """ + super().__init__(**kwargs) + self.lock_duration = lock_duration + self.max_size_in_megabytes = max_size_in_megabytes + self.requires_duplicate_detection = requires_duplicate_detection + self.requires_session = requires_session + 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.forward_to = forward_to + self.user_metadata = user_metadata + 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 + self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to + self.max_message_size_in_kilobytes = max_message_size_in_kilobytes + + +class QueueDescriptionEntry(_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 + :ivar base: Base URL for the query. + :vartype base: str + :ivar id: The URL of the GET request. + :vartype id: str + :ivar title: The name of the queue. + :vartype title: str + :ivar published: The timestamp for when this queue was published. + :vartype published: ~datetime.datetime + :ivar updated: The timestamp for when this queue was last updated. + :vartype updated: ~datetime.datetime + :ivar author: The author that created this resource. + :vartype author: ~azure.servicebus.management._generated.models.ResponseAuthor + :ivar link: The URL for the HTTP request. + :vartype link: ~azure.servicebus.management._generated.models.ResponseLink + :ivar content: The QueueDescription. + :vartype 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' + "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": "str", "xml": {"ns": "http://www.w3.org/2005/Atom"}}, + "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): + *, + base: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + title: Optional[str] = None, + published: Optional[datetime.datetime] = None, + updated: Optional[datetime.datetime] = None, + author: Optional["_models.ResponseAuthor"] = None, + link: Optional["_models.ResponseLink"] = None, + content: Optional["_models.QueueDescriptionEntryContent"] = None, + **kwargs: Any + ) -> None: + """ + :keyword base: Base URL for the query. + :paramtype base: str + :keyword id: The URL of the GET request. + :paramtype id: str + :keyword title: The name of the queue. + :paramtype title: str + :keyword published: The timestamp for when this queue was published. + :paramtype published: ~datetime.datetime + :keyword updated: The timestamp for when this queue was last updated. + :paramtype updated: ~datetime.datetime + :keyword author: The author that created this resource. + :paramtype author: ~azure.servicebus.management._generated.models.ResponseAuthor + :keyword link: The URL for the HTTP request. + :paramtype link: ~azure.servicebus.management._generated.models.ResponseLink + :keyword content: The QueueDescription. + :paramtype content: ~azure.servicebus.management._generated.models.QueueDescriptionEntryContent + """ + super().__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 QueueDescriptionEntryContent(_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 + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of content in queue response. Required. + :vartype type: str + :ivar queue_description: Description of a Service Bus queue resource. Required. + :vartype queue_description: ~azure.servicebus.management._generated.models.QueueDescription """ - _attribute_map = { - 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, - 'queue_description': {'key': 'QueueDescription', 'type': 'QueueDescription'}, + _validation = { + "type": {"required": True}, + "queue_description": {"required": True}, } - _xml_map = { - 'ns': 'http://www.w3.org/2005/Atom' + + _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) + def __init__(self, *, type: str, queue_description: "_models.QueueDescription", **kwargs: Any) -> None: + """ + :keyword type: Type of content in queue response. Required. + :paramtype type: str + :keyword queue_description: Description of a Service Bus queue resource. Required. + :paramtype queue_description: ~azure.servicebus.management._generated.models.QueueDescription + """ + super().__init__(**kwargs) + self.type = type + self.queue_description = queue_description -class QueueDescriptionFeed(msrest.serialization.Model): +class QueueDescriptionFeed(_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] + :ivar id: URL of the list queues query. + :vartype id: str + :ivar title: The entity type for the feed. + :vartype title: JSON + :ivar updated: Datetime of the query. + :vartype updated: ~datetime.datetime + :ivar link: Links to paginated response. + :vartype link: ~azure.servicebus.management._generated.models.ResponseLink + :ivar entry: Queue entries. + :vartype entry: ~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' - } + "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]", + "xml": {"itemsName": "link", "itemsNs": "http://www.w3.org/2005/Atom"}, + }, + "entry": { + "key": "entry", + "type": "[QueueDescriptionEntry]", + "xml": {"itemsName": "entry", "itemsNs": "http://www.w3.org/2005/Atom"}, + }, + } + _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): + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + title: Optional[JSON] = None, + updated: Optional[datetime.datetime] = None, + link: Optional[List["_models.ResponseLink"]] = None, + entry: Optional[List["_models.QueueDescriptionEntry"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: URL of the list queues query. + :paramtype id: str + :keyword title: The entity type for the feed. + :paramtype title: JSON + :keyword updated: Datetime of the query. + :paramtype updated: ~datetime.datetime + :keyword link: Links to paginated response. + :paramtype link: ~azure.servicebus.management._generated.models.ResponseLink + :keyword entry: Queue entries. + :paramtype entry: ~azure.servicebus.management._generated.models.QueueDescriptionEntry + """ + super().__init__(**kwargs) + self.id = id + self.title = title + self.updated = updated + self.link = link + self.entry = entry + + +class ResponseAuthor(_serialization.Model): """The author that created this resource. - :param name: The Service Bus namespace. - :type name: str + :ivar name: The Service Bus namespace. + :vartype name: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str', 'xml': {'ns': 'http://www.w3.org/2005/Atom'}}, - } - _xml_map = { - 'name': 'author', 'ns': 'http://www.w3.org/2005/Atom' + "name": {"key": "name", "type": "str", "xml": {"ns": "http://www.w3.org/2005/Atom"}}, } + _xml_map = {"name": "author", "ns": "http://www.w3.org/2005/Atom"} - def __init__( - self, - **kwargs - ): - super(ResponseAuthor, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: The Service Bus namespace. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name -class ResponseLink(msrest.serialization.Model): +class ResponseLink(_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 + :ivar href: The URL of the GET request. + :vartype href: str + :ivar rel: What the link href is relative to. + :vartype 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' + "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) + def __init__(self, *, href: Optional[str] = None, rel: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword href: The URL of the GET request. + :paramtype href: str + :keyword rel: What the link href is relative to. + :paramtype rel: str + """ + super().__init__(**kwargs) + self.href = href + self.rel = rel -class RuleDescription(msrest.serialization.Model): +class RuleDescription(_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 rule was created. - :type created_at: ~datetime.datetime - :param name: - :type name: str + :ivar filter: + :vartype filter: ~azure.servicebus.management._generated.models.RuleFilter + :ivar action: + :vartype action: ~azure.servicebus.management._generated.models.RuleAction + :ivar created_at: The exact time the rule was created. + :vartype created_at: ~datetime.datetime + :ivar name: + :vartype name: str """ _attribute_map = { - 'filter': {'key': 'filter', 'type': 'RuleFilter'}, - 'action': {'key': 'action', 'type': 'RuleAction'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601', 'xml': {'name': 'CreatedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'name': {'key': 'name', 'type': 'str', 'xml': {'name': 'Name', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - } - _xml_map = { - 'name': 'RuleDescription', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' - } + "filter": {"key": "filter", "type": "RuleFilter"}, + "action": {"key": "action", "type": "RuleAction"}, + "created_at": { + "key": "createdAt", + "type": "iso-8601", + "xml": {"name": "CreatedAt", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "name": { + "key": "name", + "type": "str", + "xml": {"name": "Name", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + } + _xml_map = {"name": "RuleDescription", "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): + *, + filter: Optional["_models.RuleFilter"] = None, # pylint: disable=redefined-builtin + action: Optional["_models.RuleAction"] = None, + created_at: Optional[datetime.datetime] = None, + name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword filter: + :paramtype filter: ~azure.servicebus.management._generated.models.RuleFilter + :keyword action: + :paramtype action: ~azure.servicebus.management._generated.models.RuleAction + :keyword created_at: The exact time the rule was created. + :paramtype created_at: ~datetime.datetime + :keyword name: + :paramtype name: str + """ + super().__init__(**kwargs) + self.filter = filter + self.action = action + self.created_at = created_at + self.name = name + + +class RuleDescriptionEntry(_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 rule was published. - :type published: ~datetime.datetime - :param updated: The timestamp for when this rule 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 RuleDescription. - :type content: ~azure.servicebus.management._generated.models.RuleDescriptionEntryContent + :ivar id: The URL of the GET request. + :vartype id: str + :ivar title: The name of the rule. + :vartype title: str + :ivar published: The timestamp for when this rule was published. + :vartype published: ~datetime.datetime + :ivar updated: The timestamp for when this rule was last updated. + :vartype updated: ~datetime.datetime + :ivar link: The URL for the HTTP request. + :vartype link: ~azure.servicebus.management._generated.models.ResponseLink + :ivar content: The RuleDescription. + :vartype 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' + "id": {"key": "id", "type": "str", "xml": {"ns": "http://www.w3.org/2005/Atom"}}, + "title": {"key": "title", "type": "str", "xml": {"ns": "http://www.w3.org/2005/Atom"}}, + "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): + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + title: Optional[str] = None, + published: Optional[datetime.datetime] = None, + updated: Optional[datetime.datetime] = None, + link: Optional["_models.ResponseLink"] = None, + content: Optional["_models.RuleDescriptionEntryContent"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The URL of the GET request. + :paramtype id: str + :keyword title: The name of the rule. + :paramtype title: str + :keyword published: The timestamp for when this rule was published. + :paramtype published: ~datetime.datetime + :keyword updated: The timestamp for when this rule was last updated. + :paramtype updated: ~datetime.datetime + :keyword link: The URL for the HTTP request. + :paramtype link: ~azure.servicebus.management._generated.models.ResponseLink + :keyword content: The RuleDescription. + :paramtype content: ~azure.servicebus.management._generated.models.RuleDescriptionEntryContent + """ + super().__init__(**kwargs) + self.id = id + self.title = title + self.published = published + self.updated = updated + self.link = link + self.content = content + + +class RuleDescriptionEntryContent(_serialization.Model): """The RuleDescription. - :param type: Type of content in rule response. - :type type: str - :param rule_description: - :type rule_description: ~azure.servicebus.management._generated.models.RuleDescription + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of content in rule response. Required. + :vartype type: str + :ivar rule_description: Required. + :vartype rule_description: ~azure.servicebus.management._generated.models.RuleDescription """ - _attribute_map = { - 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, - 'rule_description': {'key': 'RuleDescription', 'type': 'RuleDescription'}, + _validation = { + "type": {"required": True}, + "rule_description": {"required": True}, } - _xml_map = { - 'ns': 'http://www.w3.org/2005/Atom' + + _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) + def __init__(self, *, type: str, rule_description: "_models.RuleDescription", **kwargs: Any) -> None: + """ + :keyword type: Type of content in rule response. Required. + :paramtype type: str + :keyword rule_description: Required. + :paramtype rule_description: ~azure.servicebus.management._generated.models.RuleDescription + """ + super().__init__(**kwargs) + self.type = type + self.rule_description = rule_description -class RuleDescriptionFeed(msrest.serialization.Model): +class RuleDescriptionFeed(_serialization.Model): """Response from listing Service Bus rules. - :param id: URL of the list rules 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: Rules entries. - :type entry: list[~azure.servicebus.management._generated.models.RuleDescriptionEntry] + :ivar id: URL of the list rules query. + :vartype id: str + :ivar title: The entity type for the feed. + :vartype title: JSON + :ivar updated: Datetime of the query. + :vartype updated: ~datetime.datetime + :ivar link: Links to paginated response. + :vartype link: ~azure.servicebus.management._generated.models.ResponseLink + :ivar entry: Rules entries. + :vartype entry: ~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' - } + "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]", + "xml": {"itemsName": "link", "itemsNs": "http://www.w3.org/2005/Atom"}, + }, + "entry": { + "key": "entry", + "type": "[RuleDescriptionEntry]", + "xml": {"itemsName": "entry", "itemsNs": "http://www.w3.org/2005/Atom"}, + }, + } + _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): + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + title: Optional[JSON] = None, + updated: Optional[datetime.datetime] = None, + link: Optional[List["_models.ResponseLink"]] = None, + entry: Optional[List["_models.RuleDescriptionEntry"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: URL of the list rules query. + :paramtype id: str + :keyword title: The entity type for the feed. + :paramtype title: JSON + :keyword updated: Datetime of the query. + :paramtype updated: ~datetime.datetime + :keyword link: Links to paginated response. + :paramtype link: ~azure.servicebus.management._generated.models.ResponseLink + :keyword entry: Rules entries. + :paramtype entry: ~azure.servicebus.management._generated.models.RuleDescriptionEntry + """ + super().__init__(**kwargs) + self.id = id + self.title = title + self.updated = updated + self.link = link + self.entry = entry + + +class ServiceBusManagementError(_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 + :ivar code: The service error code. + :vartype code: int + :ivar detail: The service error message. + :vartype detail: str """ _attribute_map = { - 'code': {'key': 'code', 'type': 'int', 'xml': {'name': 'Code'}}, - 'detail': {'key': 'detail', 'type': 'str', 'xml': {'name': 'Detail'}}, + "code": {"key": "code", "type": "int", "xml": {"name": "Code"}}, + "detail": {"key": "detail", "type": "str", "xml": {"name": "Detail"}}, } - def __init__( - self, - **kwargs - ): - super(ServiceBusManagementError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.detail = kwargs.get('detail', None) + def __init__(self, *, code: Optional[int] = None, detail: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword code: The service error code. + :paramtype code: int + :keyword detail: The service error message. + :paramtype detail: str + """ + super().__init__(**kwargs) + self.code = code + self.detail = detail class SqlRuleAction(RuleAction): @@ -1159,496 +2042,1089 @@ class SqlRuleAction(RuleAction): All required parameters must be populated in order to send to Azure. - :param type: Required. Constant filled by server. - :type type: str - :param sql_expression: - :type sql_expression: str - :param compatibility_level: - :type compatibility_level: str - :param parameters: - :type parameters: list[~azure.servicebus.management._generated.models.KeyValue] - :param requires_preprocessing: - :type requires_preprocessing: bool + :ivar type: Required. + :vartype type: str + :ivar sql_expression: + :vartype sql_expression: str + :ivar compatibility_level: + :vartype compatibility_level: str + :ivar parameters: + :vartype parameters: ~azure.servicebus.management._generated.models.KeyValue + :ivar requires_preprocessing: + :vartype requires_preprocessing: bool """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _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': {'name': 'SqlExpression', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'str', 'xml': {'name': 'CompatibilityLevel', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'parameters': {'key': 'parameters', 'type': '[KeyValue]', 'xml': {'name': 'Parameters', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'KeyValueOfstringanyType', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool', 'xml': {'name': 'RequiresPreprocessing', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + "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": { + "name": "SqlExpression", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "compatibility_level": { + "key": "compatibilityLevel", + "type": "str", + "xml": { + "name": "CompatibilityLevel", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "parameters": { + "key": "parameters", + "type": "[KeyValue]", + "xml": { + "name": "Parameters", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + "wrapped": True, + "itemsName": "KeyValueOfstringanyType", + "itemsNs": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "requires_preprocessing": { + "key": "requiresPreprocessing", + "type": "bool", + "xml": { + "name": "RequiresPreprocessing", + "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) - self.compatibility_level = kwargs.get('compatibility_level', "20") - self.parameters = kwargs.get('parameters', None) - self.requires_preprocessing = kwargs.get('requires_preprocessing', None) - - -class SubscriptionDescription(msrest.serialization.Model): + *, + sql_expression: Optional[str] = None, + compatibility_level: str = "20", + parameters: Optional[List["_models.KeyValue"]] = None, + requires_preprocessing: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword sql_expression: + :paramtype sql_expression: str + :keyword compatibility_level: + :paramtype compatibility_level: str + :keyword parameters: + :paramtype parameters: ~azure.servicebus.management._generated.models.KeyValue + :keyword requires_preprocessing: + :paramtype requires_preprocessing: bool + """ + super().__init__(**kwargs) + self.type: str = "SqlRuleAction" + self.sql_expression = sql_expression + self.compatibility_level = compatibility_level + self.parameters = parameters + self.requires_preprocessing = requires_preprocessing + + +class SubscriptionDescription(_serialization.Model): # pylint: disable=too-many-instance-attributes """Description of a Service Bus subscription resource. - :param lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time + :ivar 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 subscription 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 + :vartype lock_duration: ~datetime.timedelta + :ivar requires_session: A value that indicates whether the subscription supports the concept of + sessions. + :vartype requires_session: bool + :ivar 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 subscription + :vartype default_message_time_to_live: ~datetime.timedelta + :ivar dead_lettering_on_message_expiration: A value that indicates whether this subscription 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 + :vartype dead_lettering_on_message_expiration: bool + :ivar dead_lettering_on_filter_evaluation_exceptions: A value that indicates whether this subscription 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 subscription. - :type message_count: int - :param max_delivery_count: The maximum delivery count. A message is automatically deadlettered + :vartype dead_lettering_on_filter_evaluation_exceptions: bool + :ivar default_rule_description: The default rule description. + :vartype default_rule_description: + ~azure.servicebus.management._generated.models.RuleDescription + :ivar message_count: The number of messages in the subscription. + :vartype message_count: int + :ivar 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 + :vartype max_delivery_count: int + :ivar 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: The name of the recipient entity to which all the messages sent to the + :vartype enable_batched_operations: bool + :ivar status: Status of a Service Bus resource. Known values are: "Active", "Creating", + "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", and + "Unknown". + :vartype status: str or ~azure.servicebus.management._generated.models.EntityStatus + :ivar forward_to: The name of the recipient entity to which all the messages sent to the subscription are forwarded to. - :type forward_to: str - :param created_at: The exact time the subscription was created. - :type created_at: ~datetime.datetime - :param updated_at: The exact time a message was updated in the subscription. - :type updated_at: ~datetime.datetime - :param accessed_at: Last time a message was sent, or the last time there was a receive request + :vartype forward_to: str + :ivar created_at: The exact time the subscription was created. + :vartype created_at: ~datetime.datetime + :ivar updated_at: The exact time a message was updated in the subscription. + :vartype updated_at: ~datetime.datetime + :ivar accessed_at: Last time a message was sent, or the last time there was a receive request to this subscription. - :type accessed_at: ~datetime.datetime - :param message_count_details: Details about the message counts in entity. - :type message_count_details: ~azure.servicebus.management._generated.models.MessageCountDetails - :param user_metadata: Metadata associated with the subscription. Maximum number of characters - is 1024. - :type user_metadata: str - :param forward_dead_lettered_messages_to: The name of the recipient entity to which all the + :vartype accessed_at: ~datetime.datetime + :ivar message_count_details: Details about the message counts in entity. + :vartype message_count_details: + ~azure.servicebus.management._generated.models.MessageCountDetails + :ivar user_metadata: Metadata associated with the subscription. Maximum number of characters is + 1024. + :vartype user_metadata: str + :ivar forward_dead_lettered_messages_to: The name of the recipient entity to which all the messages sent to the subscription are forwarded to. - :type forward_dead_lettered_messages_to: str - :param auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the subscription is + :vartype forward_dead_lettered_messages_to: str + :ivar auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the subscription 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 + :vartype auto_delete_on_idle: ~datetime.timedelta + :ivar entity_availability_status: Availability status of the entity. Known values are: + "Available", "Limited", "Renaming", "Restoring", and "Unknown". + :vartype entity_availability_status: str or ~azure.servicebus.management._generated.models.EntityAvailabilityStatus """ _attribute_map = { - 'lock_duration': {'key': 'lockDuration', 'type': 'duration', 'xml': {'name': 'LockDuration', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_session': {'key': 'requiresSession', 'type': 'bool', 'xml': {'name': 'RequiresSession', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'default_message_time_to_live': {'key': 'defaultMessageTimeToLive', 'type': 'duration', 'xml': {'name': 'DefaultMessageTimeToLive', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'dead_lettering_on_message_expiration': {'key': 'deadLetteringOnMessageExpiration', 'type': 'bool', 'xml': {'name': 'DeadLetteringOnMessageExpiration', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'deadLetteringOnFilterEvaluationExceptions', 'type': 'bool', 'xml': {'name': 'DeadLetteringOnFilterEvaluationExceptions', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'message_count': {'key': 'messageCount', 'type': 'int', 'xml': {'name': 'MessageCount', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int', 'xml': {'name': 'MaxDeliveryCount', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_batched_operations': {'key': 'enableBatchedOperations', 'type': 'bool', 'xml': {'name': 'EnableBatchedOperations', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'status': {'key': 'status', 'type': 'str', 'xml': {'name': 'Status', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'forward_to': {'key': 'forwardTo', 'type': 'str', 'xml': {'name': 'ForwardTo', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601', 'xml': {'name': 'CreatedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'updated_at': {'key': 'updatedAt', 'type': 'iso-8601', 'xml': {'name': 'UpdatedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'accessed_at': {'key': 'accessedAt', 'type': 'iso-8601', 'xml': {'name': 'AccessedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'message_count_details': {'key': 'messageCountDetails', 'type': 'MessageCountDetails'}, - 'user_metadata': {'key': 'userMetadata', 'type': 'str', 'xml': {'name': 'UserMetadata', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'forward_dead_lettered_messages_to': {'key': 'forwardDeadLetteredMessagesTo', 'type': 'str', 'xml': {'name': 'ForwardDeadLetteredMessagesTo', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'auto_delete_on_idle': {'key': 'autoDeleteOnIdle', 'type': 'duration', 'xml': {'name': 'AutoDeleteOnIdle', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'entity_availability_status': {'key': 'entityAvailabilityStatus', 'type': 'str', 'xml': {'name': 'EntityAvailabilityStatus', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + "lock_duration": { + "key": "lockDuration", + "type": "duration", + "xml": { + "name": "LockDuration", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "requires_session": { + "key": "requiresSession", + "type": "bool", + "xml": { + "name": "RequiresSession", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "default_message_time_to_live": { + "key": "defaultMessageTimeToLive", + "type": "duration", + "xml": { + "name": "DefaultMessageTimeToLive", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "dead_lettering_on_message_expiration": { + "key": "deadLetteringOnMessageExpiration", + "type": "bool", + "xml": { + "name": "DeadLetteringOnMessageExpiration", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "dead_lettering_on_filter_evaluation_exceptions": { + "key": "deadLetteringOnFilterEvaluationExceptions", + "type": "bool", + "xml": { + "name": "DeadLetteringOnFilterEvaluationExceptions", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "default_rule_description": {"key": "defaultRuleDescription", "type": "RuleDescription"}, + "message_count": { + "key": "messageCount", + "type": "int", + "xml": { + "name": "MessageCount", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "max_delivery_count": { + "key": "maxDeliveryCount", + "type": "int", + "xml": { + "name": "MaxDeliveryCount", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "enable_batched_operations": { + "key": "enableBatchedOperations", + "type": "bool", + "xml": { + "name": "EnableBatchedOperations", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "status": { + "key": "status", + "type": "str", + "xml": {"name": "Status", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "forward_to": { + "key": "forwardTo", + "type": "str", + "xml": {"name": "ForwardTo", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "created_at": { + "key": "createdAt", + "type": "iso-8601", + "xml": {"name": "CreatedAt", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "updated_at": { + "key": "updatedAt", + "type": "iso-8601", + "xml": {"name": "UpdatedAt", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "accessed_at": { + "key": "accessedAt", + "type": "iso-8601", + "xml": {"name": "AccessedAt", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "message_count_details": {"key": "messageCountDetails", "type": "MessageCountDetails"}, + "user_metadata": { + "key": "userMetadata", + "type": "str", + "xml": { + "name": "UserMetadata", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "forward_dead_lettered_messages_to": { + "key": "forwardDeadLetteredMessagesTo", + "type": "str", + "xml": { + "name": "ForwardDeadLetteredMessagesTo", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "auto_delete_on_idle": { + "key": "autoDeleteOnIdle", + "type": "duration", + "xml": { + "name": "AutoDeleteOnIdle", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "entity_availability_status": { + "key": "entityAvailabilityStatus", + "type": "str", + "xml": { + "name": "EntityAvailabilityStatus", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, } _xml_map = { - 'name': 'SubscriptionDescription', '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, - **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.user_metadata = kwargs.get('user_metadata', None) - self.forward_dead_lettered_messages_to = kwargs.get('forward_dead_lettered_messages_to', 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): + *, + lock_duration: Optional[datetime.timedelta] = None, + requires_session: Optional[bool] = None, + default_message_time_to_live: Optional[datetime.timedelta] = None, + dead_lettering_on_message_expiration: Optional[bool] = None, + dead_lettering_on_filter_evaluation_exceptions: Optional[bool] = None, + default_rule_description: Optional["_models.RuleDescription"] = None, + message_count: Optional[int] = None, + max_delivery_count: Optional[int] = None, + enable_batched_operations: Optional[bool] = None, + status: Optional[Union[str, "_models.EntityStatus"]] = 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["_models.MessageCountDetails"] = None, + user_metadata: Optional[str] = None, + forward_dead_lettered_messages_to: Optional[str] = None, + auto_delete_on_idle: Optional[datetime.timedelta] = None, + entity_availability_status: Optional[Union[str, "_models.EntityAvailabilityStatus"]] = None, + **kwargs: Any + ) -> None: + """ + :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. + :paramtype lock_duration: ~datetime.timedelta + :keyword requires_session: A value that indicates whether the subscription supports the concept + of sessions. + :paramtype 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. + :paramtype default_message_time_to_live: ~datetime.timedelta + :keyword dead_lettering_on_message_expiration: A value that indicates whether this subscription + has dead letter support when a message expires. + :paramtype dead_lettering_on_message_expiration: bool + :keyword dead_lettering_on_filter_evaluation_exceptions: A value that indicates whether this + subscription has dead letter support when a message expires. + :paramtype dead_lettering_on_filter_evaluation_exceptions: bool + :keyword default_rule_description: The default rule description. + :paramtype default_rule_description: + ~azure.servicebus.management._generated.models.RuleDescription + :keyword message_count: The number of messages in the subscription. + :paramtype 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. + :paramtype max_delivery_count: int + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :paramtype enable_batched_operations: bool + :keyword status: Status of a Service Bus resource. Known values are: "Active", "Creating", + "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", and + "Unknown". + :paramtype status: str or ~azure.servicebus.management._generated.models.EntityStatus + :keyword forward_to: The name of the recipient entity to which all the messages sent to the + subscription are forwarded to. + :paramtype forward_to: str + :keyword created_at: The exact time the subscription was created. + :paramtype created_at: ~datetime.datetime + :keyword updated_at: The exact time a message was updated in the subscription. + :paramtype updated_at: ~datetime.datetime + :keyword accessed_at: Last time a message was sent, or the last time there was a receive + request to this subscription. + :paramtype accessed_at: ~datetime.datetime + :keyword message_count_details: Details about the message counts in entity. + :paramtype message_count_details: + ~azure.servicebus.management._generated.models.MessageCountDetails + :keyword user_metadata: Metadata associated with the subscription. Maximum number of characters + is 1024. + :paramtype user_metadata: str + :keyword forward_dead_lettered_messages_to: The name of the recipient entity to which all the + messages sent to the subscription are forwarded to. + :paramtype forward_dead_lettered_messages_to: str + :keyword auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the subscription is + automatically deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: ~datetime.timedelta + :keyword entity_availability_status: Availability status of the entity. Known values are: + "Available", "Limited", "Renaming", "Restoring", and "Unknown". + :paramtype entity_availability_status: str or + ~azure.servicebus.management._generated.models.EntityAvailabilityStatus + """ + super().__init__(**kwargs) + self.lock_duration = lock_duration + self.requires_session = requires_session + self.default_message_time_to_live = default_message_time_to_live + 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.default_rule_description = default_rule_description + self.message_count = message_count + self.max_delivery_count = max_delivery_count + self.enable_batched_operations = enable_batched_operations + self.status = status + 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.user_metadata = user_metadata + self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to + self.auto_delete_on_idle = auto_delete_on_idle + self.entity_availability_status = entity_availability_status + + +class SubscriptionDescriptionEntry(_serialization.Model): """Represents an entry in the feed when querying subscriptions. - :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 subscription was published. - :type published: ~datetime.datetime - :param updated: The timestamp for when this subscription 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 SubscriptionDescription. - :type content: + :ivar id: The URL of the GET request. + :vartype id: str + :ivar title: The name of the subscription. + :vartype title: str + :ivar published: The timestamp for when this subscription was published. + :vartype published: ~datetime.datetime + :ivar updated: The timestamp for when this subscription was last updated. + :vartype updated: ~datetime.datetime + :ivar link: The URL for the HTTP request. + :vartype link: ~azure.servicebus.management._generated.models.ResponseLink + :ivar content: The SubscriptionDescription. + :vartype 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' + "id": {"key": "id", "type": "str", "xml": {"ns": "http://www.w3.org/2005/Atom"}}, + "title": {"key": "title", "type": "str", "xml": {"ns": "http://www.w3.org/2005/Atom"}}, + "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): + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + title: Optional[str] = None, + published: Optional[datetime.datetime] = None, + updated: Optional[datetime.datetime] = None, + link: Optional["_models.ResponseLink"] = None, + content: Optional["_models.SubscriptionDescriptionEntryContent"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The URL of the GET request. + :paramtype id: str + :keyword title: The name of the subscription. + :paramtype title: str + :keyword published: The timestamp for when this subscription was published. + :paramtype published: ~datetime.datetime + :keyword updated: The timestamp for when this subscription was last updated. + :paramtype updated: ~datetime.datetime + :keyword link: The URL for the HTTP request. + :paramtype link: ~azure.servicebus.management._generated.models.ResponseLink + :keyword content: The SubscriptionDescription. + :paramtype content: + ~azure.servicebus.management._generated.models.SubscriptionDescriptionEntryContent + """ + super().__init__(**kwargs) + self.id = id + self.title = title + self.published = published + self.updated = updated + self.link = link + self.content = content + + +class SubscriptionDescriptionEntryContent(_serialization.Model): """The SubscriptionDescription. - :param type: Type of content in subscription response. - :type type: str - :param subscription_description: Description of a Service Bus subscription resource. - :type subscription_description: + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of content in subscription response. Required. + :vartype type: str + :ivar subscription_description: Description of a Service Bus subscription resource. Required. + :vartype subscription_description: ~azure.servicebus.management._generated.models.SubscriptionDescription """ - _attribute_map = { - 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, - 'subscription_description': {'key': 'SubscriptionDescription', 'type': 'SubscriptionDescription'}, + _validation = { + "type": {"required": True}, + "subscription_description": {"required": True}, } - _xml_map = { - 'ns': 'http://www.w3.org/2005/Atom' + + _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): + self, *, type: str, subscription_description: "_models.SubscriptionDescription", **kwargs: Any + ) -> None: + """ + :keyword type: Type of content in subscription response. Required. + :paramtype type: str + :keyword subscription_description: Description of a Service Bus subscription resource. + Required. + :paramtype subscription_description: + ~azure.servicebus.management._generated.models.SubscriptionDescription + """ + super().__init__(**kwargs) + self.type = type + self.subscription_description = subscription_description + + +class SubscriptionDescriptionFeed(_serialization.Model): """Response from listing Service Bus subscriptions. - :param id: URL of the list subscriptions 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: Subscription entries. - :type entry: list[~azure.servicebus.management._generated.models.SubscriptionDescriptionEntry] + :ivar id: URL of the list subscriptions query. + :vartype id: str + :ivar title: The entity type for the feed. + :vartype title: JSON + :ivar updated: Datetime of the query. + :vartype updated: ~datetime.datetime + :ivar link: Links to paginated response. + :vartype link: ~azure.servicebus.management._generated.models.ResponseLink + :ivar entry: Subscription entries. + :vartype entry: ~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' - } + "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]", + "xml": {"itemsName": "link", "itemsNs": "http://www.w3.org/2005/Atom"}, + }, + "entry": { + "key": "entry", + "type": "[SubscriptionDescriptionEntry]", + "xml": {"itemsName": "entry", "itemsNs": "http://www.w3.org/2005/Atom"}, + }, + } + _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): + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + title: Optional[JSON] = None, + updated: Optional[datetime.datetime] = None, + link: Optional[List["_models.ResponseLink"]] = None, + entry: Optional[List["_models.SubscriptionDescriptionEntry"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: URL of the list subscriptions query. + :paramtype id: str + :keyword title: The entity type for the feed. + :paramtype title: JSON + :keyword updated: Datetime of the query. + :paramtype updated: ~datetime.datetime + :keyword link: Links to paginated response. + :paramtype link: ~azure.servicebus.management._generated.models.ResponseLink + :keyword entry: Subscription entries. + :paramtype entry: ~azure.servicebus.management._generated.models.SubscriptionDescriptionEntry + """ + super().__init__(**kwargs) + self.id = id + self.title = title + self.updated = updated + self.link = link + self.entry = entry + + +class TopicDescription(_serialization.Model): # pylint: disable=too-many-instance-attributes """Description of a Service Bus topic resource. - :param default_message_time_to_live: ISO 8601 default message timespan to live value. This is + :ivar 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 + :vartype default_message_time_to_live: ~datetime.timedelta + :ivar 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 + :vartype max_size_in_megabytes: int + :ivar 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 + :vartype requires_duplicate_detection: bool + :ivar 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 + :vartype duplicate_detection_history_time_window: ~datetime.timedelta + :ivar 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 topic, 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 + :vartype enable_batched_operations: bool + :ivar size_in_bytes: The size of the topic, in bytes. + :vartype size_in_bytes: int + :ivar filtering_messages_before_publishing: Filter messages before publishing. + :vartype filtering_messages_before_publishing: bool + :ivar 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 topic was created. - :type created_at: ~datetime.datetime - :param updated_at: The exact time a message was updated in the topic. - :type updated_at: ~datetime.datetime - :param accessed_at: Last time a message was sent, or the last time there was a receive request + :vartype is_anonymous_accessible: bool + :ivar authorization_rules: Authorization rules for resource. + :vartype authorization_rules: ~azure.servicebus.management._generated.models.AuthorizationRule + :ivar status: Status of a Service Bus resource. Known values are: "Active", "Creating", + "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", and + "Unknown". + :vartype status: str or ~azure.servicebus.management._generated.models.EntityStatus + :ivar created_at: The exact time the topic was created. + :vartype created_at: ~datetime.datetime + :ivar updated_at: The exact time a message was updated in the topic. + :vartype updated_at: ~datetime.datetime + :ivar accessed_at: Last time a message was sent, or the last time there was a receive request to this topic. - :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 entity. - :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 + :vartype accessed_at: ~datetime.datetime + :ivar support_ordering: Indicates if messages are received in the same order they are sent. If + partitioned topics, defaults to false, and setting it to true has no effect. For unpartitioned + topics, setting it to false will improve perf, but messages may not be received in the order + they are sent. + :vartype support_ordering: bool + :ivar message_count_details: Details about the message counts in entity. + :vartype message_count_details: + ~azure.servicebus.management._generated.models.MessageCountDetails + :ivar subscription_count: The number of subscriptions in the topic. + :vartype subscription_count: int + :ivar 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 + :vartype auto_delete_on_idle: ~datetime.timedelta + :ivar enable_partitioning: A value that indicates whether the topic is to be partitioned across + multiple message brokers. + :vartype enable_partitioning: bool + :ivar entity_availability_status: Availability status of the entity. Known values are: + "Available", "Limited", "Renaming", "Restoring", and "Unknown". + :vartype 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 + :ivar enable_subscription_partitioning: A value that indicates whether the topic's subscription + is to be partitioned. + :vartype enable_subscription_partitioning: bool + :ivar enable_express: A value that indicates whether Express Entities are enabled. An express topic 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 - :param max_message_size_in_kilobytes: The maximum size in kilobytes of message payload that can + :vartype enable_express: bool + :ivar user_metadata: Metadata associated with the topic. + :vartype user_metadata: str + :ivar max_message_size_in_kilobytes: The maximum size in kilobytes of message payload that can be accepted by the topic. - :type max_message_size_in_kilobytes: int + :vartype max_message_size_in_kilobytes: int """ _attribute_map = { - 'default_message_time_to_live': {'key': 'defaultMessageTimeToLive', 'type': 'duration', 'xml': {'name': 'DefaultMessageTimeToLive', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_size_in_megabytes': {'key': 'maxSizeInMegabytes', 'type': 'long', 'xml': {'name': 'MaxSizeInMegabytes', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_duplicate_detection': {'key': 'requiresDuplicateDetection', 'type': 'bool', 'xml': {'name': 'RequiresDuplicateDetection', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'duplicate_detection_history_time_window': {'key': 'duplicateDetectionHistoryTimeWindow', 'type': 'duration', 'xml': {'name': 'DuplicateDetectionHistoryTimeWindow', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_batched_operations': {'key': 'enableBatchedOperations', 'type': 'bool', 'xml': {'name': 'EnableBatchedOperations', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'size_in_bytes': {'key': 'sizeInBytes', 'type': 'int', 'xml': {'name': 'SizeInBytes', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'filtering_messages_before_publishing': {'key': 'filteringMessagesBeforePublishing', 'type': 'bool', 'xml': {'name': 'FilteringMessagesBeforePublishing', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'is_anonymous_accessible': {'key': 'isAnonymousAccessible', 'type': 'bool', 'xml': {'name': 'IsAnonymousAccessible', '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': {'name': 'Status', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601', 'xml': {'name': 'CreatedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'updated_at': {'key': 'updatedAt', 'type': 'iso-8601', 'xml': {'name': 'UpdatedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'accessed_at': {'key': 'accessedAt', 'type': 'iso-8601', 'xml': {'name': 'AccessedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'support_ordering': {'key': 'supportOrdering', 'type': 'bool', 'xml': {'name': 'SupportOrdering', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'message_count_details': {'key': 'messageCountDetails', 'type': 'MessageCountDetails'}, - 'subscription_count': {'key': 'subscriptionCount', 'type': 'int', 'xml': {'name': 'SubscriptionCount', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'auto_delete_on_idle': {'key': 'autoDeleteOnIdle', 'type': 'duration', 'xml': {'name': 'AutoDeleteOnIdle', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_partitioning': {'key': 'enablePartitioning', 'type': 'bool', 'xml': {'name': 'EnablePartitioning', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'entity_availability_status': {'key': 'entityAvailabilityStatus', 'type': 'str', 'xml': {'name': 'EntityAvailabilityStatus', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_subscription_partitioning': {'key': 'enableSubscriptionPartitioning', 'type': 'bool', 'xml': {'name': 'EnableSubscriptionPartitioning', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_express': {'key': 'enableExpress', 'type': 'bool', 'xml': {'name': 'EnableExpress', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'user_metadata': {'key': 'userMetadata', 'type': 'str', 'xml': {'name': 'UserMetadata', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_message_size_in_kilobytes': {'key': 'maxMessageSizeInKilobytes', 'type': 'int', 'xml': {'name': 'MaxMessageSizeInKilobytes', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - } - _xml_map = { - 'name': 'TopicDescription', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' - } + "default_message_time_to_live": { + "key": "defaultMessageTimeToLive", + "type": "duration", + "xml": { + "name": "DefaultMessageTimeToLive", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "max_size_in_megabytes": { + "key": "maxSizeInMegabytes", + "type": "int", + "xml": { + "name": "MaxSizeInMegabytes", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "requires_duplicate_detection": { + "key": "requiresDuplicateDetection", + "type": "bool", + "xml": { + "name": "RequiresDuplicateDetection", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "duplicate_detection_history_time_window": { + "key": "duplicateDetectionHistoryTimeWindow", + "type": "duration", + "xml": { + "name": "DuplicateDetectionHistoryTimeWindow", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "enable_batched_operations": { + "key": "enableBatchedOperations", + "type": "bool", + "xml": { + "name": "EnableBatchedOperations", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "size_in_bytes": { + "key": "sizeInBytes", + "type": "int", + "xml": {"name": "SizeInBytes", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "filtering_messages_before_publishing": { + "key": "filteringMessagesBeforePublishing", + "type": "bool", + "xml": { + "name": "FilteringMessagesBeforePublishing", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "is_anonymous_accessible": { + "key": "isAnonymousAccessible", + "type": "bool", + "xml": { + "name": "IsAnonymousAccessible", + "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": {"name": "Status", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "created_at": { + "key": "createdAt", + "type": "iso-8601", + "xml": {"name": "CreatedAt", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "updated_at": { + "key": "updatedAt", + "type": "iso-8601", + "xml": {"name": "UpdatedAt", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "accessed_at": { + "key": "accessedAt", + "type": "iso-8601", + "xml": {"name": "AccessedAt", "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"}, + }, + "support_ordering": { + "key": "supportOrdering", + "type": "bool", + "xml": { + "name": "SupportOrdering", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "message_count_details": {"key": "messageCountDetails", "type": "MessageCountDetails"}, + "subscription_count": { + "key": "subscriptionCount", + "type": "int", + "xml": { + "name": "SubscriptionCount", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "auto_delete_on_idle": { + "key": "autoDeleteOnIdle", + "type": "duration", + "xml": { + "name": "AutoDeleteOnIdle", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "enable_partitioning": { + "key": "enablePartitioning", + "type": "bool", + "xml": { + "name": "EnablePartitioning", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "entity_availability_status": { + "key": "entityAvailabilityStatus", + "type": "str", + "xml": { + "name": "EntityAvailabilityStatus", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "enable_subscription_partitioning": { + "key": "enableSubscriptionPartitioning", + "type": "bool", + "xml": { + "name": "EnableSubscriptionPartitioning", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "enable_express": { + "key": "enableExpress", + "type": "bool", + "xml": { + "name": "EnableExpress", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "user_metadata": { + "key": "userMetadata", + "type": "str", + "xml": { + "name": "UserMetadata", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "max_message_size_in_kilobytes": { + "key": "maxMessageSizeInKilobytes", + "type": "int", + "xml": { + "name": "MaxMessageSizeInKilobytes", + "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) - self.max_message_size_in_kilobytes = kwargs.get('max_message_size_in_kilobytes', None) - - -class TopicDescriptionEntry(msrest.serialization.Model): + *, + 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["_models.AuthorizationRule"]] = None, + status: Optional[Union[str, "_models.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["_models.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, "_models.EntityAvailabilityStatus"]] = None, + enable_subscription_partitioning: Optional[bool] = None, + enable_express: Optional[bool] = None, + user_metadata: Optional[str] = None, + max_message_size_in_kilobytes: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :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. + :paramtype 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. + :paramtype max_size_in_megabytes: int + :keyword requires_duplicate_detection: A value indicating if this topic requires duplicate + detection. + :paramtype 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. + :paramtype duplicate_detection_history_time_window: ~datetime.timedelta + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :paramtype enable_batched_operations: bool + :keyword size_in_bytes: The size of the topic, in bytes. + :paramtype size_in_bytes: int + :keyword filtering_messages_before_publishing: Filter messages before publishing. + :paramtype filtering_messages_before_publishing: bool + :keyword is_anonymous_accessible: A value indicating if the resource can be accessed without + authorization. + :paramtype is_anonymous_accessible: bool + :keyword authorization_rules: Authorization rules for resource. + :paramtype authorization_rules: + ~azure.servicebus.management._generated.models.AuthorizationRule + :keyword status: Status of a Service Bus resource. Known values are: "Active", "Creating", + "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", and + "Unknown". + :paramtype status: str or ~azure.servicebus.management._generated.models.EntityStatus + :keyword created_at: The exact time the topic was created. + :paramtype created_at: ~datetime.datetime + :keyword updated_at: The exact time a message was updated in the topic. + :paramtype updated_at: ~datetime.datetime + :keyword accessed_at: Last time a message was sent, or the last time there was a receive + request to this topic. + :paramtype accessed_at: ~datetime.datetime + :keyword support_ordering: Indicates if messages are received in the same order they are sent. + If partitioned topics, defaults to false, and setting it to true has no effect. For + unpartitioned topics, setting it to false will improve perf, but messages may not be received + in the order they are sent. + :paramtype support_ordering: bool + :keyword message_count_details: Details about the message counts in entity. + :paramtype message_count_details: + ~azure.servicebus.management._generated.models.MessageCountDetails + :keyword subscription_count: The number of subscriptions in the topic. + :paramtype subscription_count: int + :keyword auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the topic is + automatically deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: ~datetime.timedelta + :keyword enable_partitioning: A value that indicates whether the topic is to be partitioned + across multiple message brokers. + :paramtype enable_partitioning: bool + :keyword entity_availability_status: Availability status of the entity. Known values are: + "Available", "Limited", "Renaming", "Restoring", and "Unknown". + :paramtype 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. + :paramtype enable_subscription_partitioning: bool + :keyword enable_express: A value that indicates whether Express Entities are enabled. An + express topic holds a message in memory temporarily before writing it to persistent storage. + :paramtype enable_express: bool + :keyword user_metadata: Metadata associated with the topic. + :paramtype user_metadata: str + :keyword max_message_size_in_kilobytes: The maximum size in kilobytes of message payload that + can be accepted by the topic. + :paramtype max_message_size_in_kilobytes: int + """ + super().__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 + self.max_message_size_in_kilobytes = max_message_size_in_kilobytes + + +class TopicDescriptionEntry(_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 topic. - :type title: object - :param published: The timestamp for when this topic was published. - :type published: ~datetime.datetime - :param updated: The timestamp for when this topic 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 TopicDescription. - :type content: ~azure.servicebus.management._generated.models.TopicDescriptionEntryContent + :ivar base: Base URL for the query. + :vartype base: str + :ivar id: The URL of the GET request. + :vartype id: str + :ivar title: The name of the topic. + :vartype title: str + :ivar published: The timestamp for when this topic was published. + :vartype published: ~datetime.datetime + :ivar updated: The timestamp for when this topic was last updated. + :vartype updated: ~datetime.datetime + :ivar author: The author that created this resource. + :vartype author: ~azure.servicebus.management._generated.models.ResponseAuthor + :ivar link: The URL for the HTTP request. + :vartype link: ~azure.servicebus.management._generated.models.ResponseLink + :ivar content: The TopicDescription. + :vartype 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' + "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": "str", "xml": {"ns": "http://www.w3.org/2005/Atom"}}, + "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): + *, + base: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + title: Optional[str] = None, + published: Optional[datetime.datetime] = None, + updated: Optional[datetime.datetime] = None, + author: Optional["_models.ResponseAuthor"] = None, + link: Optional["_models.ResponseLink"] = None, + content: Optional["_models.TopicDescriptionEntryContent"] = None, + **kwargs: Any + ) -> None: + """ + :keyword base: Base URL for the query. + :paramtype base: str + :keyword id: The URL of the GET request. + :paramtype id: str + :keyword title: The name of the topic. + :paramtype title: str + :keyword published: The timestamp for when this topic was published. + :paramtype published: ~datetime.datetime + :keyword updated: The timestamp for when this topic was last updated. + :paramtype updated: ~datetime.datetime + :keyword author: The author that created this resource. + :paramtype author: ~azure.servicebus.management._generated.models.ResponseAuthor + :keyword link: The URL for the HTTP request. + :paramtype link: ~azure.servicebus.management._generated.models.ResponseLink + :keyword content: The TopicDescription. + :paramtype content: ~azure.servicebus.management._generated.models.TopicDescriptionEntryContent + """ + super().__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(_serialization.Model): """The TopicDescription. - :param type: Type of content in topic response. - :type type: str - :param topic_description: Description of a Service Bus topic resource. - :type topic_description: ~azure.servicebus.management._generated.models.TopicDescription + All required parameters must be populated in order to send to Azure. + + :ivar type: Type of content in topic response. Required. + :vartype type: str + :ivar topic_description: Description of a Service Bus topic resource. Required. + :vartype topic_description: ~azure.servicebus.management._generated.models.TopicDescription """ - _attribute_map = { - 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True}}, - 'topic_description': {'key': 'TopicDescription', 'type': 'TopicDescription'}, + _validation = { + "type": {"required": True}, + "topic_description": {"required": True}, } - _xml_map = { - 'ns': 'http://www.w3.org/2005/Atom' + + _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) + def __init__(self, *, type: str, topic_description: "_models.TopicDescription", **kwargs: Any) -> None: + """ + :keyword type: Type of content in topic response. Required. + :paramtype type: str + :keyword topic_description: Description of a Service Bus topic resource. Required. + :paramtype topic_description: ~azure.servicebus.management._generated.models.TopicDescription + """ + super().__init__(**kwargs) + self.type = type + self.topic_description = topic_description -class TopicDescriptionFeed(msrest.serialization.Model): +class TopicDescriptionFeed(_serialization.Model): """Response from listing Service Bus topics. - :param id: URL of the list topics 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] + :ivar id: URL of the list topics query. + :vartype id: str + :ivar title: The entity type for the feed. + :vartype title: JSON + :ivar updated: Datetime of the query. + :vartype updated: ~datetime.datetime + :ivar link: Links to paginated response. + :vartype link: ~azure.servicebus.management._generated.models.ResponseLink + :ivar entry: Topic entries. + :vartype entry: ~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' - } + "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]", + "xml": {"itemsName": "link", "itemsNs": "http://www.w3.org/2005/Atom"}, + }, + "entry": { + "key": "entry", + "type": "[TopicDescriptionEntry]", + "xml": {"itemsName": "entry", "itemsNs": "http://www.w3.org/2005/Atom"}, + }, + } + _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) + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + title: Optional[JSON] = None, + updated: Optional[datetime.datetime] = None, + link: Optional[List["_models.ResponseLink"]] = None, + entry: Optional[List["_models.TopicDescriptionEntry"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: URL of the list topics query. + :paramtype id: str + :keyword title: The entity type for the feed. + :paramtype title: JSON + :keyword updated: Datetime of the query. + :paramtype updated: ~datetime.datetime + :keyword link: Links to paginated response. + :paramtype link: ~azure.servicebus.management._generated.models.ResponseLink + :keyword entry: Topic entries. + :paramtype entry: ~azure.servicebus.management._generated.models.TopicDescriptionEntry + """ + super().__init__(**kwargs) + self.id = id + self.title = title + self.updated = updated + self.link = link + self.entry = entry class TrueFilter(SqlFilter): @@ -1656,33 +3132,89 @@ class TrueFilter(SqlFilter): All required parameters must be populated in order to send to Azure. - :param type: Required. Constant filled by server. - :type type: str - :param sql_expression: - :type sql_expression: str - :param compatibility_level: - :type compatibility_level: str - :param parameters: - :type parameters: list[~azure.servicebus.management._generated.models.KeyValue] - :param requires_preprocessing: - :type requires_preprocessing: bool + :ivar type: Required. + :vartype type: str + :ivar sql_expression: + :vartype sql_expression: str + :ivar compatibility_level: + :vartype compatibility_level: str + :ivar parameters: + :vartype parameters: ~azure.servicebus.management._generated.models.KeyValue + :ivar requires_preprocessing: + :vartype requires_preprocessing: bool """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _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': {'name': 'SqlExpression', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'str', 'xml': {'name': 'CompatibilityLevel', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'parameters': {'key': 'parameters', 'type': '[KeyValue]', 'xml': {'name': 'Parameters', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'KeyValueOfstringanyType', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool', 'xml': {'name': 'RequiresPreprocessing', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, + "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": { + "name": "SqlExpression", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "compatibility_level": { + "key": "compatibilityLevel", + "type": "str", + "xml": { + "name": "CompatibilityLevel", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "parameters": { + "key": "parameters", + "type": "[KeyValue]", + "xml": { + "name": "Parameters", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + "wrapped": True, + "itemsName": "KeyValueOfstringanyType", + "itemsNs": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, + "requires_preprocessing": { + "key": "requiresPreprocessing", + "type": "bool", + "xml": { + "name": "RequiresPreprocessing", + "ns": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", + }, + }, } def __init__( self, - **kwargs - ): - super(TrueFilter, self).__init__(**kwargs) - self.type = 'TrueFilter' + *, + sql_expression: Optional[str] = None, + compatibility_level: str = "20", + parameters: Optional[List["_models.KeyValue"]] = None, + requires_preprocessing: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword sql_expression: + :paramtype sql_expression: str + :keyword compatibility_level: + :paramtype compatibility_level: str + :keyword parameters: + :paramtype parameters: ~azure.servicebus.management._generated.models.KeyValue + :keyword requires_preprocessing: + :paramtype requires_preprocessing: bool + """ + super().__init__( + sql_expression=sql_expression, + compatibility_level=compatibility_level, + parameters=parameters, + requires_preprocessing=requires_preprocessing, + **kwargs + ) + self.type: str = "TrueFilter" 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 deleted file mode 100644 index f5fb21d3c4a9..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_models_py3.py +++ /dev/null @@ -1,1932 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import List, Optional, Union - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - -from ._service_bus_management_client_enums import * - - -class AuthorizationRule(msrest.serialization.Model): - """Authorization rule of an entity. - - :param type: The authorization type. - :type type: str - :param claim_type: The claim type. - :type claim_type: str - :param claim_value: The claim value. - :type claim_value: str - :param rights: Access rights of the entity. Values are 'Send', 'Listen', or 'Manage'. - :type rights: list[str or ~azure.servicebus.management._generated.models.AccessRights] - :param created_time: The date and time when the authorization rule was created. - :type created_time: ~datetime.datetime - :param modified_time: The date and time when the authorization rule was modified. - :type modified_time: ~datetime.datetime - :param key_name: The authorization rule key name. - :type key_name: str - :param primary_key: The primary key of the authorization rule. - :type primary_key: str - :param secondary_key: The primary key of the authorization rule. - :type secondary_key: str - """ - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str', 'xml': {'attr': True, 'prefix': 'i', 'ns': 'http://www.w3.org/2001/XMLSchema-instance'}}, - 'claim_type': {'key': 'claimType', 'type': 'str', 'xml': {'name': 'ClaimType', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'claim_value': {'key': 'claimValue', 'type': 'str', 'xml': {'name': 'ClaimValue', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'rights': {'key': 'rights', 'type': '[str]', 'xml': {'name': 'Rights', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'AccessRights', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601', 'xml': {'name': 'CreatedTime', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'modified_time': {'key': 'modifiedTime', 'type': 'iso-8601', 'xml': {'name': 'ModifiedTime', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'key_name': {'key': 'keyName', 'type': 'str', 'xml': {'name': 'KeyName', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'primary_key': {'key': 'primaryKey', 'type': 'str', 'xml': {'name': 'PrimaryKey', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str', 'xml': {'name': 'SecondaryKey', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - } - _xml_map = { - 'name': 'AuthorizationRule', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' - } - - def __init__( - self, - *, - type: Optional[str] = None, - claim_type: Optional[str] = None, - claim_value: Optional[str] = None, - rights: Optional[List[Union[str, "AccessRights"]]] = None, - created_time: Optional[datetime.datetime] = None, - modified_time: Optional[datetime.datetime] = None, - key_name: Optional[str] = None, - primary_key: Optional[str] = None, - secondary_key: Optional[str] = None, - **kwargs - ): - super(AuthorizationRule, self).__init__(**kwargs) - self.type = type - self.claim_type = claim_type - self.claim_value = claim_value - self.rights = rights - self.created_time = created_time - self.modified_time = modified_time - self.key_name = key_name - self.primary_key = primary_key - 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, SqlFilter. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. Constant filled by server. - :type type: str - """ - - _validation = { - 'type': {'required': True}, - } - - _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', 'SqlFilter': 'SqlFilter'} - } - _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. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. 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] - """ - - _validation = { - 'type': {'required': True}, - } - - _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': {'name': 'CorrelationId', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'message_id': {'key': 'messageId', 'type': 'str', 'xml': {'name': 'MessageId', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'to': {'key': 'to', 'type': 'str', 'xml': {'name': 'To', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'reply_to': {'key': 'replyTo', 'type': 'str', 'xml': {'name': 'ReplyTo', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'label': {'key': 'label', 'type': 'str', 'xml': {'name': 'Label', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'session_id': {'key': 'sessionId', 'type': 'str', 'xml': {'name': 'SessionId', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'reply_to_session_id': {'key': 'replyToSessionId', 'type': 'str', 'xml': {'name': 'ReplyToSessionId', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'content_type': {'key': 'contentType', 'type': 'str', 'xml': {'name': 'ContentType', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'properties': {'key': 'properties', 'type': '[KeyValue]', 'xml': {'name': 'Properties', '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. - - :param content: QueueDescription for the new queue. - :type content: ~azure.servicebus.management._generated.models.CreateQueueBodyContent - """ - - _attribute_map = { - 'content': {'key': 'content', 'type': 'CreateQueueBodyContent'}, - } - _xml_map = { - 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' - } - - def __init__( - self, - *, - content: Optional["CreateQueueBodyContent"] = None, - **kwargs - ): - super(CreateQueueBody, self).__init__(**kwargs) - self.content = content - - -class CreateQueueBodyContent(msrest.serialization.Model): - """QueueDescription for the new queue. - - :param type: MIME type of content. - :type type: str - :param queue_description: Properties of the new queue. - :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, - *, - type: Optional[str] = "application/xml", - queue_description: Optional["QueueDescription"] = None, - **kwargs - ): - super(CreateQueueBodyContent, self).__init__(**kwargs) - self.type = type - self.queue_description = queue_description - - -class CreateRuleBody(msrest.serialization.Model): - """The request body for creating a rule. - - :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 subscription. - - :param content: SubscriptionDescription for the new subscription. - :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): - """SubscriptionDescription for the new subscription. - - :param type: MIME type of content. - :type type: str - :param subscription_description: Subscription 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. - - :param content: TopicDescription for the new topic. - :type content: ~azure.servicebus.management._generated.models.CreateTopicBodyContent - """ - - _attribute_map = { - 'content': {'key': 'content', 'type': 'CreateTopicBodyContent'}, - } - _xml_map = { - 'name': 'entry', 'ns': 'http://www.w3.org/2005/Atom' - } - - def __init__( - self, - *, - content: Optional["CreateTopicBodyContent"] = None, - **kwargs - ): - super(CreateTopicBody, self).__init__(**kwargs) - self.content = content - - -class CreateTopicBodyContent(msrest.serialization.Model): - """TopicDescription for the new topic. - - :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 - """ - - _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] = "application/xml", - topic_description: Optional["TopicDescription"] = None, - **kwargs - ): - super(CreateTopicBodyContent, self).__init__(**kwargs) - self.type = type - 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. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. Constant filled by server. - :type type: str - """ - - _validation = { - 'type': {'required': True}, - } - - _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. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. Constant filled by server. - :type type: str - """ - - _validation = { - 'type': {'required': True}, - } - - _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 SqlFilter(RuleFilter): - """SqlFilter. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FalseFilter, TrueFilter. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. Constant filled by server. - :type type: str - :param sql_expression: - :type sql_expression: str - :param compatibility_level: - :type compatibility_level: str - :param parameters: - :type parameters: list[~azure.servicebus.management._generated.models.KeyValue] - :param requires_preprocessing: - :type requires_preprocessing: bool - """ - - _validation = { - 'type': {'required': True}, - } - - _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': {'name': 'SqlExpression', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'str', 'xml': {'name': 'CompatibilityLevel', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'parameters': {'key': 'parameters', 'type': '[KeyValue]', 'xml': {'name': 'Parameters', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'KeyValueOfstringanyType', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool', 'xml': {'name': 'RequiresPreprocessing', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - } - - _subtype_map = { - 'type': {'FalseFilter': 'FalseFilter', 'TrueFilter': 'TrueFilter'} - } - - def __init__( - self, - *, - sql_expression: Optional[str] = None, - compatibility_level: Optional[str] = "20", - parameters: Optional[List["KeyValue"]] = None, - requires_preprocessing: Optional[bool] = None, - **kwargs - ): - super(SqlFilter, self).__init__(**kwargs) - self.type: str = 'SqlFilter' - self.sql_expression = sql_expression - self.compatibility_level = compatibility_level - self.parameters = parameters - self.requires_preprocessing = requires_preprocessing - - -class FalseFilter(SqlFilter): - """FalseFilter. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. Constant filled by server. - :type type: str - :param sql_expression: - :type sql_expression: str - :param compatibility_level: - :type compatibility_level: str - :param parameters: - :type parameters: list[~azure.servicebus.management._generated.models.KeyValue] - :param requires_preprocessing: - :type requires_preprocessing: bool - """ - - _validation = { - 'type': {'required': True}, - } - - _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': {'name': 'SqlExpression', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'str', 'xml': {'name': 'CompatibilityLevel', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'parameters': {'key': 'parameters', 'type': '[KeyValue]', 'xml': {'name': 'Parameters', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'KeyValueOfstringanyType', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool', 'xml': {'name': 'RequiresPreprocessing', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - } - - def __init__( - self, - *, - sql_expression: Optional[str] = None, - compatibility_level: Optional[str] = "20", - parameters: Optional[List["KeyValue"]] = None, - requires_preprocessing: Optional[bool] = None, - **kwargs - ): - super(FalseFilter, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, parameters=parameters, requires_preprocessing=requires_preprocessing, **kwargs) - self.type: str = 'FalseFilter' - - -class KeyValue(msrest.serialization.Model): - """Key Values of custom properties. - - :param key: - :type key: str - :param value: - :type value: str - """ - - _attribute_map = { - 'key': {'key': 'key', 'type': 'str', 'xml': {'name': 'Key', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'value': {'key': 'value', 'type': 'str', 'xml': {'name': 'Value', '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 entity. - - :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 = { - 'active_message_count': {'key': 'activeMessageCount', 'type': 'int', 'xml': {'name': 'ActiveMessageCount', 'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, - 'dead_letter_message_count': {'key': 'deadLetterMessageCount', 'type': 'int', 'xml': {'name': 'DeadLetterMessageCount', 'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, - 'scheduled_message_count': {'key': 'scheduledMessageCount', 'type': 'int', 'xml': {'name': 'ScheduledMessageCount', 'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, - 'transfer_dead_letter_message_count': {'key': 'transferDeadLetterMessageCount', 'type': 'int', 'xml': {'name': 'TransferDeadLetterMessageCount', 'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, - 'transfer_message_count': {'key': 'transferMessageCount', 'type': 'int', 'xml': {'name': 'TransferMessageCount', 'prefix': 'd2p1', 'ns': 'http://schemas.microsoft.com/netservices/2011/06/servicebus'}}, - } - _xml_map = { - 'name': 'CountDetails', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' - } - - def __init__( - self, - *, - active_message_count: Optional[int] = None, - dead_letter_message_count: Optional[int] = None, - scheduled_message_count: Optional[int] = None, - transfer_dead_letter_message_count: Optional[int] = None, - transfer_message_count: Optional[int] = None, - **kwargs - ): - super(MessageCountDetails, self).__init__(**kwargs) - self.active_message_count = active_message_count - self.dead_letter_message_count = dead_letter_message_count - self.scheduled_message_count = scheduled_message_count - self.transfer_dead_letter_message_count = transfer_dead_letter_message_count - self.transfer_message_count = transfer_message_count - - -class NamespaceProperties(msrest.serialization.Model): - """The metadata related to a Service Bus namespace. - - :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 = { - 'alias': {'key': 'alias', 'type': 'str', 'xml': {'name': 'Alias', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'created_time': {'key': 'createdTime', 'type': 'iso-8601', 'xml': {'name': 'CreatedTime', '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': {'name': 'MessagingUnits', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'modified_time': {'key': 'modifiedTime', 'type': 'iso-8601', 'xml': {'name': 'ModifiedTime', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'name': {'key': 'name', 'type': 'str', 'xml': {'name': 'Name', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'namespace_type': {'key': 'namespaceType', 'type': 'str', 'xml': {'name': 'NamespaceType', '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: long - :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 forward_to: The name of the recipient entity to which all the messages sent to the queue - are forwarded to. - :type forward_to: str - :param user_metadata: Custom metdata that user can associate with the description. Max length - is 1024 chars. - :type user_metadata: str - :param created_at: The exact time the queue was created. - :type created_at: ~datetime.datetime - :param updated_at: The exact time the entity description was last updated. - :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 entity. - :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 - :param forward_dead_lettered_messages_to: The name of the recipient entity to which all the - dead-lettered messages of this subscription are forwarded to. - :type forward_dead_lettered_messages_to: str - :param max_message_size_in_kilobytes: The maximum size in kilobytes of message payload that can - be accepted by the queue. - :type max_message_size_in_kilobytes: int - """ - - _attribute_map = { - 'lock_duration': {'key': 'lockDuration', 'type': 'duration', 'xml': {'name': 'LockDuration', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_size_in_megabytes': {'key': 'maxSizeInMegabytes', 'type': 'long', 'xml': {'name': 'MaxSizeInMegabytes', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_duplicate_detection': {'key': 'requiresDuplicateDetection', 'type': 'bool', 'xml': {'name': 'RequiresDuplicateDetection', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_session': {'key': 'requiresSession', 'type': 'bool', 'xml': {'name': 'RequiresSession', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'default_message_time_to_live': {'key': 'defaultMessageTimeToLive', 'type': 'duration', 'xml': {'name': 'DefaultMessageTimeToLive', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'dead_lettering_on_message_expiration': {'key': 'deadLetteringOnMessageExpiration', 'type': 'bool', 'xml': {'name': 'DeadLetteringOnMessageExpiration', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'duplicate_detection_history_time_window': {'key': 'duplicateDetectionHistoryTimeWindow', 'type': 'duration', 'xml': {'name': 'DuplicateDetectionHistoryTimeWindow', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int', 'xml': {'name': 'MaxDeliveryCount', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_batched_operations': {'key': 'enableBatchedOperations', 'type': 'bool', 'xml': {'name': 'EnableBatchedOperations', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'size_in_bytes': {'key': 'sizeInBytes', 'type': 'int', 'xml': {'name': 'SizeInBytes', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'message_count': {'key': 'messageCount', 'type': 'int', 'xml': {'name': 'MessageCount', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'is_anonymous_accessible': {'key': 'isAnonymousAccessible', 'type': 'bool', 'xml': {'name': 'IsAnonymousAccessible', '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': {'name': 'Status', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'forward_to': {'key': 'forwardTo', 'type': 'str', 'xml': {'name': 'ForwardTo', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'user_metadata': {'key': 'userMetadata', 'type': 'str', 'xml': {'name': 'UserMetadata', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601', 'xml': {'name': 'CreatedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'updated_at': {'key': 'updatedAt', 'type': 'iso-8601', 'xml': {'name': 'UpdatedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'accessed_at': {'key': 'accessedAt', 'type': 'iso-8601', 'xml': {'name': 'AccessedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'support_ordering': {'key': 'supportOrdering', 'type': 'bool', 'xml': {'name': 'SupportOrdering', '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': {'name': 'AutoDeleteOnIdle', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_partitioning': {'key': 'enablePartitioning', 'type': 'bool', 'xml': {'name': 'EnablePartitioning', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'entity_availability_status': {'key': 'entityAvailabilityStatus', 'type': 'str', 'xml': {'name': 'EntityAvailabilityStatus', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_express': {'key': 'enableExpress', 'type': 'bool', 'xml': {'name': 'EnableExpress', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'forward_dead_lettered_messages_to': {'key': 'forwardDeadLetteredMessagesTo', 'type': 'str', 'xml': {'name': 'ForwardDeadLetteredMessagesTo', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_message_size_in_kilobytes': {'key': 'maxMessageSizeInKilobytes', 'type': 'int', 'xml': {'name': 'MaxMessageSizeInKilobytes', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - } - _xml_map = { - 'name': 'QueueDescription', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' - } - - def __init__( - self, - *, - lock_duration: Optional[datetime.timedelta] = None, - max_size_in_megabytes: Optional[int] = None, - requires_duplicate_detection: Optional[bool] = None, - requires_session: Optional[bool] = 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, - forward_to: Optional[str] = None, - user_metadata: Optional[str] = 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, - forward_dead_lettered_messages_to: Optional[str] = None, - max_message_size_in_kilobytes: Optional[int] = None, - **kwargs - ): - super(QueueDescription, self).__init__(**kwargs) - self.lock_duration = lock_duration - self.max_size_in_megabytes = max_size_in_megabytes - self.requires_duplicate_detection = requires_duplicate_detection - self.requires_session = requires_session - 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.forward_to = forward_to - self.user_metadata = user_metadata - 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 - self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to - self.max_message_size_in_kilobytes = max_message_size_in_kilobytes - - -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, - *, - 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["QueueDescriptionEntryContent"] = None, - **kwargs - ): - super(QueueDescriptionEntry, 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 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, - *, - type: Optional[str] = None, - queue_description: Optional["QueueDescription"] = None, - **kwargs - ): - super(QueueDescriptionEntryContent, self).__init__(**kwargs) - self.type = type - self.queue_description = queue_description - - -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, - *, - id: Optional[str] = None, - title: Optional[object] = None, - updated: Optional[datetime.datetime] = None, - link: Optional[List["ResponseLink"]] = None, - entry: Optional[List["QueueDescriptionEntry"]] = None, - **kwargs - ): - super(QueueDescriptionFeed, self).__init__(**kwargs) - self.id = id - self.title = title - self.updated = updated - self.link = link - self.entry = entry - - -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 = { - 'name': 'author', 'ns': 'http://www.w3.org/2005/Atom' - } - - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): - super(ResponseAuthor, self).__init__(**kwargs) - self.name = name - - -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, - *, - href: Optional[str] = None, - rel: Optional[str] = None, - **kwargs - ): - super(ResponseLink, self).__init__(**kwargs) - self.href = href - self.rel = rel - - -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 rule 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': {'name': 'CreatedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'name': {'key': 'name', 'type': 'str', 'xml': {'name': 'Name', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - } - _xml_map = { - 'name': 'RuleDescription', '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(RuleDescription, self).__init__(**kwargs) - self.filter = filter - self.action = action - self.created_at = created_at - self.name = name - - -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 rule was published. - :type published: ~datetime.datetime - :param updated: The timestamp for when this rule 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 RuleDescription. - :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, - *, - 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(RuleDescriptionEntry, self).__init__(**kwargs) - self.id = id - self.title = title - self.published = published - self.updated = updated - self.link = link - self.content = content - - -class RuleDescriptionEntryContent(msrest.serialization.Model): - """The RuleDescription. - - :param type: Type of content in rule 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, - *, - type: Optional[str] = None, - rule_description: Optional["RuleDescription"] = None, - **kwargs - ): - super(RuleDescriptionEntryContent, self).__init__(**kwargs) - self.type = type - self.rule_description = rule_description - - -class RuleDescriptionFeed(msrest.serialization.Model): - """Response from listing Service Bus rules. - - :param id: URL of the list rules 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: Rules 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): - """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', 'xml': {'name': 'Code'}}, - 'detail': {'key': 'detail', 'type': 'str', 'xml': {'name': 'Detail'}}, - } - - def __init__( - self, - *, - code: Optional[int] = None, - detail: Optional[str] = None, - **kwargs - ): - super(ServiceBusManagementError, self).__init__(**kwargs) - self.code = code - self.detail = detail - - -class SqlRuleAction(RuleAction): - """SqlRuleAction. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. Constant filled by server. - :type type: str - :param sql_expression: - :type sql_expression: str - :param compatibility_level: - :type compatibility_level: str - :param parameters: - :type parameters: list[~azure.servicebus.management._generated.models.KeyValue] - :param requires_preprocessing: - :type requires_preprocessing: bool - """ - - _validation = { - 'type': {'required': True}, - } - - _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': {'name': 'SqlExpression', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'str', 'xml': {'name': 'CompatibilityLevel', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'parameters': {'key': 'parameters', 'type': '[KeyValue]', 'xml': {'name': 'Parameters', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'KeyValueOfstringanyType', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool', 'xml': {'name': 'RequiresPreprocessing', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - } - - def __init__( - self, - *, - sql_expression: Optional[str] = None, - compatibility_level: Optional[str] = "20", - parameters: Optional[List["KeyValue"]] = None, - requires_preprocessing: Optional[bool] = None, - **kwargs - ): - super(SqlRuleAction, self).__init__(**kwargs) - self.type: str = 'SqlRuleAction' - self.sql_expression = sql_expression - self.compatibility_level = compatibility_level - self.parameters = parameters - self.requires_preprocessing = requires_preprocessing - - -class SubscriptionDescription(msrest.serialization.Model): - """Description of a Service Bus subscription 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 subscription 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 subscription - 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 - subscription 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 subscription. - :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: The name of the recipient entity to which all the messages sent to the - subscription are forwarded to. - :type forward_to: str - :param created_at: The exact time the subscription was created. - :type created_at: ~datetime.datetime - :param updated_at: The exact time a message was updated in the subscription. - :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 subscription. - :type accessed_at: ~datetime.datetime - :param message_count_details: Details about the message counts in entity. - :type message_count_details: ~azure.servicebus.management._generated.models.MessageCountDetails - :param user_metadata: Metadata associated with the subscription. Maximum number of characters - is 1024. - :type user_metadata: str - :param forward_dead_lettered_messages_to: The name of the recipient entity to which all the - messages sent to the subscription are forwarded to. - :type forward_dead_lettered_messages_to: str - :param auto_delete_on_idle: ISO 8601 timeSpan idle interval after which the subscription 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': {'name': 'LockDuration', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_session': {'key': 'requiresSession', 'type': 'bool', 'xml': {'name': 'RequiresSession', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'default_message_time_to_live': {'key': 'defaultMessageTimeToLive', 'type': 'duration', 'xml': {'name': 'DefaultMessageTimeToLive', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'dead_lettering_on_message_expiration': {'key': 'deadLetteringOnMessageExpiration', 'type': 'bool', 'xml': {'name': 'DeadLetteringOnMessageExpiration', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'deadLetteringOnFilterEvaluationExceptions', 'type': 'bool', 'xml': {'name': 'DeadLetteringOnFilterEvaluationExceptions', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'message_count': {'key': 'messageCount', 'type': 'int', 'xml': {'name': 'MessageCount', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_delivery_count': {'key': 'maxDeliveryCount', 'type': 'int', 'xml': {'name': 'MaxDeliveryCount', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_batched_operations': {'key': 'enableBatchedOperations', 'type': 'bool', 'xml': {'name': 'EnableBatchedOperations', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'status': {'key': 'status', 'type': 'str', 'xml': {'name': 'Status', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'forward_to': {'key': 'forwardTo', 'type': 'str', 'xml': {'name': 'ForwardTo', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601', 'xml': {'name': 'CreatedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'updated_at': {'key': 'updatedAt', 'type': 'iso-8601', 'xml': {'name': 'UpdatedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'accessed_at': {'key': 'accessedAt', 'type': 'iso-8601', 'xml': {'name': 'AccessedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'message_count_details': {'key': 'messageCountDetails', 'type': 'MessageCountDetails'}, - 'user_metadata': {'key': 'userMetadata', 'type': 'str', 'xml': {'name': 'UserMetadata', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'forward_dead_lettered_messages_to': {'key': 'forwardDeadLetteredMessagesTo', 'type': 'str', 'xml': {'name': 'ForwardDeadLetteredMessagesTo', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'auto_delete_on_idle': {'key': 'autoDeleteOnIdle', 'type': 'duration', 'xml': {'name': 'AutoDeleteOnIdle', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'entity_availability_status': {'key': 'entityAvailabilityStatus', 'type': 'str', 'xml': {'name': 'EntityAvailabilityStatus', '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, - *, - lock_duration: Optional[datetime.timedelta] = None, - requires_session: Optional[bool] = None, - default_message_time_to_live: 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, - status: Optional[Union[str, "EntityStatus"]] = 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, - user_metadata: Optional[str] = None, - forward_dead_lettered_messages_to: Optional[str] = None, - auto_delete_on_idle: Optional[datetime.timedelta] = None, - entity_availability_status: Optional[Union[str, "EntityAvailabilityStatus"]] = None, - **kwargs - ): - 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.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.status = status - 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.user_metadata = user_metadata - self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to - 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 subscriptions. - - :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 subscription was published. - :type published: ~datetime.datetime - :param updated: The timestamp for when this subscription 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 SubscriptionDescription. - :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 SubscriptionDescription. - - :param type: Type of content in subscription response. - :type type: str - :param subscription_description: Description of a Service Bus subscription 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 subscriptions. - - :param id: URL of the list subscriptions 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: Subscription 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 topic, 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 topic was created. - :type created_at: ~datetime.datetime - :param updated_at: The exact time a message was updated in the topic. - :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 topic. - :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 entity. - :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 - topic 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 - :param max_message_size_in_kilobytes: The maximum size in kilobytes of message payload that can - be accepted by the topic. - :type max_message_size_in_kilobytes: int - """ - - _attribute_map = { - 'default_message_time_to_live': {'key': 'defaultMessageTimeToLive', 'type': 'duration', 'xml': {'name': 'DefaultMessageTimeToLive', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_size_in_megabytes': {'key': 'maxSizeInMegabytes', 'type': 'long', 'xml': {'name': 'MaxSizeInMegabytes', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_duplicate_detection': {'key': 'requiresDuplicateDetection', 'type': 'bool', 'xml': {'name': 'RequiresDuplicateDetection', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'duplicate_detection_history_time_window': {'key': 'duplicateDetectionHistoryTimeWindow', 'type': 'duration', 'xml': {'name': 'DuplicateDetectionHistoryTimeWindow', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_batched_operations': {'key': 'enableBatchedOperations', 'type': 'bool', 'xml': {'name': 'EnableBatchedOperations', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'size_in_bytes': {'key': 'sizeInBytes', 'type': 'int', 'xml': {'name': 'SizeInBytes', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'filtering_messages_before_publishing': {'key': 'filteringMessagesBeforePublishing', 'type': 'bool', 'xml': {'name': 'FilteringMessagesBeforePublishing', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'is_anonymous_accessible': {'key': 'isAnonymousAccessible', 'type': 'bool', 'xml': {'name': 'IsAnonymousAccessible', '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': {'name': 'Status', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601', 'xml': {'name': 'CreatedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'updated_at': {'key': 'updatedAt', 'type': 'iso-8601', 'xml': {'name': 'UpdatedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'accessed_at': {'key': 'accessedAt', 'type': 'iso-8601', 'xml': {'name': 'AccessedAt', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'support_ordering': {'key': 'supportOrdering', 'type': 'bool', 'xml': {'name': 'SupportOrdering', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'message_count_details': {'key': 'messageCountDetails', 'type': 'MessageCountDetails'}, - 'subscription_count': {'key': 'subscriptionCount', 'type': 'int', 'xml': {'name': 'SubscriptionCount', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'auto_delete_on_idle': {'key': 'autoDeleteOnIdle', 'type': 'duration', 'xml': {'name': 'AutoDeleteOnIdle', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_partitioning': {'key': 'enablePartitioning', 'type': 'bool', 'xml': {'name': 'EnablePartitioning', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'entity_availability_status': {'key': 'entityAvailabilityStatus', 'type': 'str', 'xml': {'name': 'EntityAvailabilityStatus', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_subscription_partitioning': {'key': 'enableSubscriptionPartitioning', 'type': 'bool', 'xml': {'name': 'EnableSubscriptionPartitioning', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'enable_express': {'key': 'enableExpress', 'type': 'bool', 'xml': {'name': 'EnableExpress', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'user_metadata': {'key': 'userMetadata', 'type': 'str', 'xml': {'name': 'UserMetadata', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'max_message_size_in_kilobytes': {'key': 'maxMessageSizeInKilobytes', 'type': 'int', 'xml': {'name': 'MaxMessageSizeInKilobytes', '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, - max_message_size_in_kilobytes: Optional[int] = 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 - self.max_message_size_in_kilobytes = max_message_size_in_kilobytes - - -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 topic. - :type title: object - :param published: The timestamp for when this topic was published. - :type published: ~datetime.datetime - :param updated: The timestamp for when this topic 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 TopicDescription. - :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 TopicDescription. - - :param type: Type of content in topic 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 topics. - - :param id: URL of the list topics 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(SqlFilter): - """TrueFilter. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. Constant filled by server. - :type type: str - :param sql_expression: - :type sql_expression: str - :param compatibility_level: - :type compatibility_level: str - :param parameters: - :type parameters: list[~azure.servicebus.management._generated.models.KeyValue] - :param requires_preprocessing: - :type requires_preprocessing: bool - """ - - _validation = { - 'type': {'required': True}, - } - - _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': {'name': 'SqlExpression', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'str', 'xml': {'name': 'CompatibilityLevel', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'parameters': {'key': 'parameters', 'type': '[KeyValue]', 'xml': {'name': 'Parameters', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect', 'wrapped': True, 'itemsName': 'KeyValueOfstringanyType', 'itemsNs': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool', 'xml': {'name': 'RequiresPreprocessing', 'ns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'}}, - } - - def __init__( - self, - *, - sql_expression: Optional[str] = None, - compatibility_level: Optional[str] = "20", - parameters: Optional[List["KeyValue"]] = None, - requires_preprocessing: Optional[bool] = None, - **kwargs - ): - super(TrueFilter, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, parameters=parameters, requires_preprocessing=requires_preprocessing, **kwargs) - self.type: str = 'TrueFilter' diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_patch.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 deleted file mode 100644 index e021a09eb502..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/models/_service_bus_management_client_enums.py +++ /dev/null @@ -1,59 +0,0 @@ -# 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 enum import Enum - -class AccessRights(str, Enum): - """Access rights of an authorization - """ - - manage = "Manage" - send = "Send" - listen = "Listen" - -class EntityAvailabilityStatus(str, Enum): - """Availability status of the entity - """ - - available = "Available" - limited = "Limited" - renaming = "Renaming" - restoring = "Restoring" - unknown = "Unknown" - -class EntityStatus(str, Enum): - """Status of a Service Bus resource - """ - - active = "Active" - creating = "Creating" - deleting = "Deleting" - disabled = "Disabled" - receive_disabled = "ReceiveDisabled" - renaming = "Renaming" - 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 eae22edb0188..31eac47d430f 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,16 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -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 +from ._operations import EntityOperations +from ._operations import ServiceBusManagementClientOperationsMixin +from ._operations import SubscriptionOperations +from ._operations import RuleOperations +from ._operations import NamespaceOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'EntityOperations', - 'ServiceBusManagementClientOperationsMixin', - 'SubscriptionOperations', - 'RuleOperations', - 'NamespaceOperations', + "EntityOperations", + "ServiceBusManagementClientOperationsMixin", + "SubscriptionOperations", + "RuleOperations", + "NamespaceOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_entity_operations.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_entity_operations.py deleted file mode 100644 index 37d66d8f5896..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_entity_operations.py +++ /dev/null @@ -1,246 +0,0 @@ -# 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 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. - - :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, - entity_name, # type: str - enrich=False, # type: Optional[bool] - api_version="2021_05", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> object - """Get the details about the Queue or Topic with the given entityName. - - Get Queue or Topic. - - :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. - :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), - 'entityName': self._serialize.url("entity_name", entity_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': '/{entityName}'} # type: ignore - - def put( - self, - entity_name, # type: str - request_body, # type: object - api_version="2021_05", # type: Optional[str] - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> object - """Create or update a queue or topic at the provided entityName. - - :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 - :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), - 'entityName': self._serialize.url("entity_name", entity_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': '/{entityName}'} # type: ignore - - def delete( - self, - entity_name, # type: str - api_version="2021_05", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> object - """Delete the Queue or Topic with the given entityName. - - Delete Queue or Topic. - - :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 - :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), - 'entityName': self._serialize.url("entity_name", entity_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': '/{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 deleted file mode 100644 index 204489b3a447..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_namespace_operations.py +++ /dev/null @@ -1,99 +0,0 @@ -# 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="2021_05", # 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/_operations.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_operations.py new file mode 100644 index 000000000000..dff64da59967 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_operations.py @@ -0,0 +1,1339 @@ +# pylint: disable=too-many-lines +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import ServiceBusManagementClientMixinABC, _format_url_section + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_entity_get_request(entity_name: str, *, enrich: bool = False, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05"] = kwargs.pop("api_version", _params.pop("api-version", "2021-05")) + accept = _headers.pop("Accept", "application/xml, application/atom+xml") + + # Construct URL + _url = "/{entityName}" + path_format_arguments = { + "entityName": _SERIALIZER.url("entity_name", entity_name, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + if enrich is not None: + _params["enrich"] = _SERIALIZER.query("enrich", enrich, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_entity_put_request( + entity_name: str, *, content: JSON, if_match: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: Literal["2021-05"] = kwargs.pop("api_version", _params.pop("api-version", "2021-05")) + accept = _headers.pop("Accept", "application/xml, application/atom+xml") + + # Construct URL + _url = "/{entityName}" + path_format_arguments = { + "entityName": _SERIALIZER.url("entity_name", entity_name, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, content=content, **kwargs) + + +def build_entity_delete_request(entity_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05"] = kwargs.pop("api_version", _params.pop("api-version", "2021-05")) + accept = _headers.pop("Accept", "application/xml, application/atom+xml") + + # Construct URL + _url = "/{entityName}" + path_format_arguments = { + "entityName": _SERIALIZER.url("entity_name", entity_name, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_service_bus_management_list_subscriptions_request( + topic_name: str, *, skip: int = 0, top: int = 100, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05"] = kwargs.pop("api_version", _params.pop("api-version", "2021-05")) + accept = _headers.pop("Accept", "application/xml, application/atom+xml") + + # Construct URL + _url = "/{topicName}/subscriptions" + path_format_arguments = { + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_service_bus_management_list_rules_request( + topic_name: str, subscription_name: str, *, skip: int = 0, top: int = 100, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05"] = kwargs.pop("api_version", _params.pop("api-version", "2021-05")) + accept = _headers.pop("Accept", "application/xml, application/atom+xml") + + # Construct URL + _url = "/{topicName}/subscriptions/{subscriptionName}/rules" + path_format_arguments = { + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_service_bus_management_list_entities_request( + entity_type: str, *, skip: int = 0, top: int = 100, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05"] = kwargs.pop("api_version", _params.pop("api-version", "2021-05")) + accept = _headers.pop("Accept", "application/xml, application/atom+xml") + + # Construct URL + _url = "/$Resources/{entityType}" + path_format_arguments = { + "entityType": _SERIALIZER.url("entity_type", entity_type, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscription_get_request( + topic_name: str, subscription_name: str, *, enrich: bool = False, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05"] = kwargs.pop("api_version", _params.pop("api-version", "2021-05")) + accept = _headers.pop("Accept", "application/xml, application/atom+xml") + + # Construct URL + _url = "/{topicName}/subscriptions/{subscriptionName}" + path_format_arguments = { + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + if enrich is not None: + _params["enrich"] = _SERIALIZER.query("enrich", enrich, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscription_put_request( + topic_name: str, subscription_name: str, *, content: JSON, if_match: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: Literal["2021-05"] = kwargs.pop("api_version", _params.pop("api-version", "2021-05")) + accept = _headers.pop("Accept", "application/xml, application/atom+xml") + + # Construct URL + _url = "/{topicName}/subscriptions/{subscriptionName}" + path_format_arguments = { + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, content=content, **kwargs) + + +def build_subscription_delete_request(topic_name: str, subscription_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05"] = kwargs.pop("api_version", _params.pop("api-version", "2021-05")) + accept = _headers.pop("Accept", "application/xml, application/atom+xml") + + # Construct URL + _url = "/{topicName}/subscriptions/{subscriptionName}" + path_format_arguments = { + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rule_get_request( + topic_name: str, subscription_name: str, rule_name: str, *, enrich: bool = False, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05"] = kwargs.pop("api_version", _params.pop("api-version", "2021-05")) + accept = _headers.pop("Accept", "application/xml, application/atom+xml") + + # Construct URL + _url = "/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + path_format_arguments = { + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + if enrich is not None: + _params["enrich"] = _SERIALIZER.query("enrich", enrich, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rule_put_request( + topic_name: str, + subscription_name: str, + rule_name: str, + *, + content: JSON, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: Literal["2021-05"] = kwargs.pop("api_version", _params.pop("api-version", "2021-05")) + accept = _headers.pop("Accept", "application/xml, application/atom+xml") + + # Construct URL + _url = "/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + path_format_arguments = { + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, content=content, **kwargs) + + +def build_rule_delete_request(topic_name: str, subscription_name: str, rule_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05"] = kwargs.pop("api_version", _params.pop("api-version", "2021-05")) + accept = _headers.pop("Accept", "application/xml, application/atom+xml") + + # Construct URL + _url = "/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + path_format_arguments = { + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_namespace_get_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05"] = kwargs.pop("api_version", _params.pop("api-version", "2021-05")) + accept = _headers.pop("Accept", "application/xml, application/atom+xml") + + # Construct URL + _url = "/$namespaceinfo" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class EntityOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.servicebus.management._generated.ServiceBusManagementClient`'s + :attr:`entity` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, entity_name: str, *, enrich: bool = False, **kwargs: Any) -> JSON: + """Get Queue or Topic. + + Get the details about the Queue or Topic with the given entityName. + + :param entity_name: The name of the queue or topic relative to the Service Bus namespace. + Required. + :type entity_name: str + :keyword enrich: A query parameter that sets enrich to true or false. Default value is False. + :paramtype enrich: bool + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_entity_get_request( + entity_name=entity_name, + enrich=enrich, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def put(self, entity_name: str, request_body: JSON, *, if_match: Optional[str] = None, **kwargs: Any) -> JSON: + """Create or update a queue or topic at the provided entityName. + + :param entity_name: The name of the queue or topic relative to the Service Bus namespace. + Required. + :type entity_name: str + :param request_body: Parameters required to make or edit a queue or topic. Required. + :type request_body: JSON + :keyword 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. Default + value is None. + :paramtype if_match: str + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/atom+xml")) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _content = self._serialize.body(request_body, "object") + + request = build_entity_put_request( + entity_name=entity_name, + if_match=if_match, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + 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, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete(self, entity_name: str, **kwargs: Any) -> JSON: + """Delete Queue or Topic. + + Delete the Queue or Topic with the given entityName. + + :param entity_name: The name of the queue or topic relative to the Service Bus namespace. + Required. + :type entity_name: str + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_entity_delete_request( + entity_name=entity_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class ServiceBusManagementClientOperationsMixin(ServiceBusManagementClientMixinABC): + @distributed_trace + def list_subscriptions(self, topic_name: str, *, skip: int = 0, top: int = 100, **kwargs: Any) -> JSON: + """Get subscriptions. + + Get the details about the subscriptions of the given topic. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :keyword skip: Default value is 0. + :paramtype skip: int + :keyword top: Default value is 100. + :paramtype top: int + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_service_bus_management_list_subscriptions_request( + topic_name=topic_name, + skip=skip, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_rules( + self, topic_name: str, subscription_name: str, *, skip: int = 0, top: int = 100, **kwargs: Any + ) -> JSON: + """Get rules of a topic subscription. + + Get the details about the rules of the given topic subscription. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :param subscription_name: name of the subscription. Required. + :type subscription_name: str + :keyword skip: Default value is 0. + :paramtype skip: int + :keyword top: Default value is 100. + :paramtype top: int + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_service_bus_management_list_rules_request( + topic_name=topic_name, + subscription_name=subscription_name, + skip=skip, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def list_entities(self, entity_type: str, *, skip: int = 0, top: int = 100, **kwargs: Any) -> JSON: + """Get Queues or topics. + + Get the details about the entities of the given Service Bus namespace. + + :param entity_type: List all queues or all topics of the service bus. Value can be "queues" or + "topics". Required. + :type entity_type: str + :keyword skip: Default value is 0. + :paramtype skip: int + :keyword top: Default value is 100. + :paramtype top: int + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_service_bus_management_list_entities_request( + entity_type=entity_type, + skip=skip, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class SubscriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.servicebus.management._generated.ServiceBusManagementClient`'s + :attr:`subscription` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, topic_name: str, subscription_name: str, *, enrich: bool = False, **kwargs: Any) -> JSON: + """Get Subscription. + + Get the details about the subscription of a topic. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :param subscription_name: name of the subscription. Required. + :type subscription_name: str + :keyword enrich: A query parameter that sets enrich to true or false. Default value is False. + :paramtype enrich: bool + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_subscription_get_request( + topic_name=topic_name, + subscription_name=subscription_name, + enrich=enrich, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def put( + self, + topic_name: str, + subscription_name: str, + request_body: JSON, + *, + if_match: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Create or update a subscription. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :param subscription_name: name of the subscription. Required. + :type subscription_name: str + :param request_body: Parameters required to make or edit a subscription. Required. + :type request_body: JSON + :keyword 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. Default + value is None. + :paramtype if_match: str + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/atom+xml")) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _content = self._serialize.body(request_body, "object") + + request = build_subscription_put_request( + topic_name=topic_name, + subscription_name=subscription_name, + if_match=if_match, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + 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, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete(self, topic_name: str, subscription_name: str, **kwargs: Any) -> JSON: + """Delete Subscription. + + Delete the subscription with the given topicName and subscriptionName. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :param subscription_name: name of the subscription. Required. + :type subscription_name: str + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_subscription_delete_request( + topic_name=topic_name, + subscription_name=subscription_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class RuleOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.servicebus.management._generated.ServiceBusManagementClient`'s + :attr:`rule` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, topic_name: str, subscription_name: str, rule_name: str, *, enrich: bool = False, **kwargs: Any + ) -> JSON: + """Get Rule. + + Get the details about the rule of a subscription of a topic. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :param subscription_name: name of the subscription. Required. + :type subscription_name: str + :param rule_name: name of the filter. Required. + :type rule_name: str + :keyword enrich: A query parameter that sets enrich to true or false. Default value is False. + :paramtype enrich: bool + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_rule_get_request( + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + enrich=enrich, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + @distributed_trace + def put( + self, + topic_name: str, + subscription_name: str, + rule_name: str, + request_body: JSON, + *, + if_match: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Create or update a rule. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :param subscription_name: name of the subscription. Required. + :type subscription_name: str + :param rule_name: name of the filter. Required. + :type rule_name: str + :param request_body: Parameters required to make or edit a rule. Required. + :type request_body: JSON + :keyword 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. Default + value is None. + :paramtype if_match: str + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/atom+xml")) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _content = self._serialize.body(request_body, "object") + + request = build_rule_put_request( + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + if_match=if_match, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + 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, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete(self, topic_name: str, subscription_name: str, rule_name: str, **kwargs: Any) -> JSON: + """Delete Subscription. + + Delete the rule with the given topicName, subscriptionName and ruleName. + + :param topic_name: name of the topic. Required. + :type topic_name: str + :param subscription_name: name of the subscription. Required. + :type subscription_name: str + :param rule_name: name of the filter. Required. + :type rule_name: str + :return: JSON + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + request = build_rule_delete_request( + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + +class NamespaceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.servicebus.management._generated.ServiceBusManagementClient`'s + :attr:`namespace` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, **kwargs: Any) -> _models.NamespacePropertiesEntry: + """Get Namespace Properties. + + Get the details about the Service Bus namespace. + + :return: NamespacePropertiesEntry + :rtype: ~azure.servicebus.management._generated.models.NamespacePropertiesEntry + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NamespacePropertiesEntry] = kwargs.pop("cls", None) + + request = build_namespace_get_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.failsafe_deserialize(_models.ServiceBusManagementError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize("NamespacePropertiesEntry", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_patch.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 deleted file mode 100644 index b058cbeba2ea..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_rule_operations.py +++ /dev/null @@ -1,270 +0,0 @@ -# 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="2021_05", # 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="2021_05", # 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="2021_05", # 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 deleted file mode 100644 index acedc853c957..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_service_bus_management_client_operations.py +++ /dev/null @@ -1,236 +0,0 @@ -# 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 ServiceBusManagementClientOperationsMixin(object): - - def list_subscriptions( - self, - topic_name, # type: str - skip=0, # type: Optional[int] - top=100, # type: Optional[int] - api_version="2021_05", # 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="2021_05", # 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 - skip=0, # type: Optional[int] - top=100, # type: Optional[int] - api_version="2021_05", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> object - """Get the details about the entities of the given Service Bus namespace. - - Get Queues or topics. - - :param entity_type: List all queues or all topics of the service bus. Value can be "queues" or - "topics". - :type entity_type: 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_entities.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'entityType': self._serialize.url("entity_type", entity_type, '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_entities.metadata = {'url': '/$Resources/{entityType}'} # type: ignore 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 deleted file mode 100644 index ae03fb550741..000000000000 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_generated/operations/_subscription_operations.py +++ /dev/null @@ -1,258 +0,0 @@ -# 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="2021_05", # 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="2021_05", # 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="2021_05", # 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/_management_client.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_management_client.py index 8e5f6e5bc7f6..45a562306153 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_management_client.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_management_client.py @@ -26,12 +26,17 @@ from ._generated.models import ( QueueDescriptionFeed, TopicDescriptionEntry, + TopicDescriptionEntryContent, + SubscriptionDescriptionEntryContent, QueueDescriptionEntry, + QueueDescriptionEntryContent, SubscriptionDescriptionFeed, SubscriptionDescriptionEntry, RuleDescriptionEntry, + RuleDescriptionEntryContent, RuleDescriptionFeed, NamespacePropertiesEntry, + NamespacePropertiesEntryContent, CreateTopicBody, CreateTopicBodyContent, TopicDescriptionFeed, @@ -68,7 +73,7 @@ ) from ._shared_key_policy import ServiceBusSharedKeyCredentialPolicy from ._generated._configuration import ServiceBusManagementClientConfiguration -from ._generated._service_bus_management_client import ( +from ._generated import ( ServiceBusManagementClient as ServiceBusManagementClientImpl, ) from . import _constants as constants @@ -119,11 +124,18 @@ def __init__( self._credential = credential self._endpoint = "https://" + fully_qualified_namespace self._config = ServiceBusManagementClientConfiguration( - self._endpoint, api_version=api_version, **kwargs + self._endpoint, + credential=self._credential, + api_version=api_version, + **kwargs ) self._pipeline = self._build_pipeline() self._impl = ServiceBusManagementClientImpl( - endpoint=fully_qualified_namespace, pipeline=self._pipeline + endpoint=fully_qualified_namespace, + credential=self._credential, + pipeline=self._pipeline, + api_version=api_version, + **kwargs ) def __enter__(self): @@ -162,42 +174,38 @@ def _build_pipeline(self, **kwargs): # pylint: disable=no-self-use transport = RequestsTransport(**kwargs) return Pipeline(transport, policies) - def _get_entity_element(self, entity_name, enrich=False, **kwargs): - # type: (str, bool, Any) -> ElementTree + def _get_entity_element( + self, entity_name: str, enrich: bool = False, **kwargs: Any + ) -> ElementTree: _validate_entity_name_type(entity_name) with _handle_response_error(): element = cast( ElementTree, - self._impl.entity.get( - entity_name, - enrich=enrich, - api_version=self._api_version, # type: ignore - **kwargs - ), + self._impl.entity.get(entity_name, enrich=enrich, **kwargs), ) return element def _get_subscription_element( - self, topic_name, subscription_name, enrich=False, **kwargs - ): - # type: (str, str, bool, Any) -> ElementTree + self, + topic_name: str, + subscription_name: str, + enrich: bool = False, + **kwargs: Any + ) -> ElementTree: _validate_topic_and_subscription_types(topic_name, subscription_name) with _handle_response_error(): element = cast( ElementTree, self._impl.subscription.get( - topic_name, - subscription_name, - enrich=enrich, - api_version=self._api_version, # type: ignore - **kwargs + topic_name, subscription_name, enrich=enrich, **kwargs ), ) return element - def _get_rule_element(self, topic_name, subscription_name, rule_name, **kwargs): - # type: (str, str, str, Any) -> ElementTree + def _get_rule_element( + self, topic_name: str, subscription_name: str, rule_name: str, **kwargs: Any + ) -> ElementTree: _validate_topic_subscription_and_rule_types( topic_name, subscription_name, rule_name ) @@ -206,12 +214,7 @@ def _get_rule_element(self, topic_name, subscription_name, rule_name, **kwargs): element = cast( ElementTree, self._impl.rule.get( - topic_name, - subscription_name, - rule_name, - enrich=False, - api_version=self._api_version, # type: ignore - **kwargs + topic_name, subscription_name, rule_name, enrich=False, **kwargs ), ) return element @@ -241,7 +244,11 @@ def _populate_header_within_kwargs(uri, header): @classmethod def from_connection_string( - cls, conn_str: str, *, api_version: Union[str, ApiVersion] = DEFAULT_VERSION, **kwargs: Any + cls, + conn_str: str, + *, + api_version: Union[str, ApiVersion] = DEFAULT_VERSION, + **kwargs: Any ) -> "ServiceBusAdministrationClient": """Create a client from connection string. @@ -283,8 +290,9 @@ def get_queue(self, queue_name: str, **kwargs: Any) -> QueueProperties: ) return queue_description - def get_queue_runtime_properties(self, queue_name, **kwargs): - # type: (str, Any) -> QueueRuntimeProperties + def get_queue_runtime_properties( + self, queue_name: str, **kwargs: Any + ) -> QueueRuntimeProperties: """Get the runtime information of a queue. :param str queue_name: The name of the queue. @@ -432,21 +440,22 @@ def create_queue( # pylint: disable=too-many-locals entry_ele = cast( ElementTree, self._impl.entity.put( - queue_name, # type: ignore - request_body, - api_version=self._api_version, # type: ignore - **kwargs + queue_name, request_body, **kwargs # type: ignore ), ) entry = QueueDescriptionEntry.deserialize(entry_ele) + # Need to cast from Optional[QueueDescriptionEntryContent] to QueueDescriptionEntryContent + # since we know for certain that `entry.content` will not be None here. + entry.content = cast(QueueDescriptionEntryContent, entry.content) result = QueueProperties._from_internal_entity( queue_name, entry.content.queue_description ) return result - def update_queue(self, queue, **kwargs): - # type: (Union[QueueProperties, Mapping], Any) -> None + def update_queue( + self, queue: Union[QueueProperties, Mapping[str, Any]], **kwargs: Any + ) -> None: """Update a queue. Before calling this method, you should use `get_queue`, `create_queue` or `list_queues` to get a @@ -474,15 +483,10 @@ def update_queue(self, queue, **kwargs): self._create_forward_to_header_tokens(to_update, kwargs) with _handle_response_error(): self._impl.entity.put( - queue.name, # type: ignore - request_body, - api_version=self._api_version, # type: ignore - if_match="*", - **kwargs + queue.name, request_body, if_match="*", **kwargs # type: ignore ) - def delete_queue(self, queue_name, **kwargs): - # type: (str, Any) -> None + def delete_queue(self, queue_name: str, **kwargs: Any) -> None: """Delete a queue. :param str queue_name: The name of the queue or @@ -494,12 +498,9 @@ def delete_queue(self, queue_name, **kwargs): if not queue_name: raise ValueError("queue_name must not be None or empty") with _handle_response_error(): - self._impl.entity.delete( - queue_name, api_version=self._api_version, **kwargs # type: ignore - ) + self._impl.entity.delete(queue_name, **kwargs) # type: ignore - def list_queues(self, **kwargs): - # type: (Any) -> ItemPaged[QueueProperties] + def list_queues(self, **kwargs: Any) -> ItemPaged[QueueProperties]: """List the queues of a ServiceBus namespace. :returns: An iterable (auto-paging) response of QueueProperties. @@ -518,13 +519,13 @@ def entry_to_qd(entry): get_next = functools.partial( get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_QUEUES), - api_version=self._api_version, # type: ignore **kwargs ) return ItemPaged(get_next, extract_data) - def list_queues_runtime_properties(self, **kwargs): - # type: (Any) -> ItemPaged[QueueRuntimeProperties] + def list_queues_runtime_properties( + self, **kwargs: Any + ) -> ItemPaged[QueueRuntimeProperties]: """List the runtime information of the queues in a ServiceBus namespace. :returns: An iterable (auto-paging) response of QueueRuntimeProperties. @@ -543,13 +544,11 @@ def entry_to_qr(entry): get_next = functools.partial( get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_QUEUES), - api_version=self._api_version, # type: ignore **kwargs ) return ItemPaged(get_next, extract_data) - def get_topic(self, topic_name, **kwargs): - # type: (str, Any) -> TopicProperties + def get_topic(self, topic_name: str, **kwargs: Any) -> TopicProperties: """Get the properties of a topic. :param str topic_name: The name of the topic. @@ -564,8 +563,9 @@ def get_topic(self, topic_name, **kwargs): ) return topic_description - def get_topic_runtime_properties(self, topic_name, **kwargs): - # type: (str, Any) -> TopicRuntimeProperties + def get_topic_runtime_properties( + self, topic_name: str, **kwargs: Any + ) -> TopicRuntimeProperties: """Get a the runtime information of a topic. :param str topic_name: The name of the topic. @@ -585,9 +585,7 @@ def create_topic( topic_name: str, *, default_message_time_to_live: Optional[Union[datetime.timedelta, str]] = None, - max_size_in_megabytes: Optional[ - int - ] = None, + max_size_in_megabytes: Optional[int] = None, requires_duplicate_detection: Optional[bool] = None, duplicate_detection_history_time_window: Optional[ Union[datetime.timedelta, str] @@ -688,20 +686,21 @@ def create_topic( entry_ele = cast( ElementTree, self._impl.entity.put( - topic_name, # type: ignore - request_body, - api_version=self._api_version, # type: ignore - **kwargs + topic_name, request_body, **kwargs # type: ignore ), ) entry = TopicDescriptionEntry.deserialize(entry_ele) + # Need to cast from Optional[TopicDescriptionEntryContent] to TopicDescriptionEntryContent + # since we know for certain that `entry.content` will not be None here. + entry.content = cast(TopicDescriptionEntryContent, entry.content) result = TopicProperties._from_internal_entity( topic_name, entry.content.topic_description ) return result - def update_topic(self, topic, **kwargs): - # type: (Union[TopicProperties, Mapping[str, Any]], Any) -> None + def update_topic( + self, topic: Union[TopicProperties, Mapping[str, Any]], **kwargs: Any + ) -> None: """Update a topic. Before calling this method, you should use `get_topic`, `create_topic` or `list_topics` to get a @@ -728,15 +727,10 @@ def update_topic(self, topic, **kwargs): request_body = create_entity_body.serialize(is_xml=True) with _handle_response_error(): self._impl.entity.put( - topic.name, # type: ignore - request_body, - api_version=self._api_version, # type: ignore - if_match="*", - **kwargs + topic.name, request_body, if_match="*", **kwargs # type: ignore ) - def delete_topic(self, topic_name, **kwargs): - # type: (str, Any) -> None + def delete_topic(self, topic_name: str, **kwargs: Any) -> None: """Delete a topic. :param str topic_name: The topic to be deleted. @@ -744,12 +738,9 @@ def delete_topic(self, topic_name, **kwargs): """ _validate_entity_name_type(topic_name) - self._impl.entity.delete( - topic_name, api_version=self._api_version, **kwargs # type: ignore - ) + self._impl.entity.delete(topic_name, **kwargs) # type: ignore - def list_topics(self, **kwargs): - # type: (Any) -> ItemPaged[TopicProperties] + def list_topics(self, **kwargs: Any) -> ItemPaged[TopicProperties]: """List the topics of a ServiceBus namespace. :returns: An iterable (auto-paging) response of TopicProperties. @@ -768,13 +759,13 @@ def entry_to_topic(entry): get_next = functools.partial( get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_TOPICS), - api_version=self._api_version, # type: ignore **kwargs ) return ItemPaged(get_next, extract_data) - def list_topics_runtime_properties(self, **kwargs): - # type: (Any) -> ItemPaged[TopicRuntimeProperties] + def list_topics_runtime_properties( + self, **kwargs: Any + ) -> ItemPaged[TopicRuntimeProperties]: """List the topics runtime information of a ServiceBus namespace. :returns: An iterable (auto-paging) response of TopicRuntimeProperties. @@ -793,13 +784,13 @@ def entry_to_topic(entry): get_next = functools.partial( get_next_template, functools.partial(self._impl.list_entities, constants.ENTITY_TYPE_TOPICS), - api_version=self._api_version, # type: ignore **kwargs ) return ItemPaged(get_next, extract_data) - def get_subscription(self, topic_name, subscription_name, **kwargs): - # type: (str, str, Any) -> SubscriptionProperties + def get_subscription( + self, topic_name: str, subscription_name: str, **kwargs: Any + ) -> SubscriptionProperties: """Get the properties of a topic subscription. :param str topic_name: The topic that owns the subscription. @@ -817,14 +808,13 @@ def get_subscription(self, topic_name, subscription_name, **kwargs): ) ) subscription = SubscriptionProperties._from_internal_entity( - entry.title, entry.content.subscription_description + subscription_name, entry.content.subscription_description ) return subscription def get_subscription_runtime_properties( - self, topic_name, subscription_name, **kwargs - ): - # type: (str, str, Any) -> SubscriptionRuntimeProperties + self, topic_name: str, subscription_name: str, **kwargs: Any + ) -> SubscriptionRuntimeProperties: """Get a topic subscription runtime info. :param str topic_name: The topic that owns the subscription. @@ -842,7 +832,7 @@ def get_subscription_runtime_properties( ) ) subscription = SubscriptionRuntimeProperties._from_internal_entity( - entry.title, entry.content.subscription_description + subscription_name, entry.content.subscription_description ) return subscription @@ -953,19 +943,25 @@ def create_subscription( topic_name, subscription_name, # type: ignore request_body, - api_version=self._api_version, # type: ignore **kwargs ), ) entry = SubscriptionDescriptionEntry.deserialize(entry_ele) + # Need to cast from Optional[SubscriptionDescriptionEntryContent] to SubscriptionDescriptionEntryContent + # since we know for certain that `entry.content` will not be None here. + entry.content = cast(SubscriptionDescriptionEntryContent, entry.content) result = SubscriptionProperties._from_internal_entity( subscription_name, entry.content.subscription_description ) return result - def update_subscription(self, topic_name, subscription, **kwargs): - # type: (str, Union[SubscriptionProperties, Mapping[str, Any]], Any) -> None + def update_subscription( + self, + topic_name: str, + subscription: Union[SubscriptionProperties, Mapping[str, Any]], + **kwargs: Any + ) -> None: """Update a subscription. Before calling this method, you should use `get_subscription`, `update_subscription` or `list_subscription` @@ -998,16 +994,12 @@ def update_subscription(self, topic_name, subscription, **kwargs): self._create_forward_to_header_tokens(to_update, kwargs) with _handle_response_error(): self._impl.subscription.put( - topic_name, - subscription.name, - request_body, - api_version=self._api_version, # type: ignore - if_match="*", - **kwargs + topic_name, subscription.name, request_body, if_match="*", **kwargs ) - def delete_subscription(self, topic_name, subscription_name, **kwargs): - # type: (str, str, Any) -> None + def delete_subscription( + self, topic_name: str, subscription_name: str, **kwargs: Any + ) -> None: """Delete a topic subscription. :param str topic_name: The topic that owns the subscription. @@ -1018,11 +1010,12 @@ def delete_subscription(self, topic_name, subscription_name, **kwargs): _validate_topic_and_subscription_types(topic_name, subscription_name) self._impl.subscription.delete( - topic_name, subscription_name, api_version=self._api_version, **kwargs # type: ignore + topic_name, subscription_name, **kwargs # type: ignore ) - def list_subscriptions(self, topic_name, **kwargs): - # type: (str, Any) -> ItemPaged[SubscriptionProperties] + def list_subscriptions( + self, topic_name: str, **kwargs: Any + ) -> ItemPaged[SubscriptionProperties]: """List the subscriptions of a ServiceBus Topic. :param str topic_name: The topic that owns the subscription. @@ -1043,13 +1036,13 @@ def entry_to_subscription(entry): get_next = functools.partial( get_next_template, functools.partial(self._impl.list_subscriptions, topic_name), - api_version=self._api_version, # type: ignore **kwargs ) return ItemPaged(get_next, extract_data) - def list_subscriptions_runtime_properties(self, topic_name, **kwargs): - # type: (str, Any) -> ItemPaged[SubscriptionRuntimeProperties] + def list_subscriptions_runtime_properties( + self, topic_name: str, **kwargs: Any + ) -> ItemPaged[SubscriptionRuntimeProperties]: """List the subscriptions runtime information of a ServiceBus Topic. :param str topic_name: The topic that owns the subscription. @@ -1070,13 +1063,13 @@ def entry_to_subscription(entry): get_next = functools.partial( get_next_template, functools.partial(self._impl.list_subscriptions, topic_name), - api_version=self._api_version, # type: ignore **kwargs ) return ItemPaged(get_next, extract_data) - def get_rule(self, topic_name, subscription_name, rule_name, **kwargs): - # type: (str, str, str, Any) -> RuleProperties + def get_rule( + self, topic_name: str, subscription_name: str, rule_name: str, **kwargs: Any + ) -> RuleProperties: """Get the properties of a topic subscription rule. :param str topic_name: The topic that owns the subscription. @@ -1111,7 +1104,7 @@ def create_rule( *, filter: Union[ # pylint: disable=redefined-builtin CorrelationRuleFilter, SqlRuleFilter - ]=TrueRuleFilter(), + ] = TrueRuleFilter(), action: Optional[SqlRuleAction] = None, **kwargs: Any ) -> RuleProperties: @@ -1153,10 +1146,12 @@ def create_rule( subscription_name, # type: ignore rule_name, request_body, - api_version=self._api_version, # type: ignore **kwargs ) entry = RuleDescriptionEntry.deserialize(entry_ele) + # Need to cast from Optional[RuleDescriptionEntryContent] to RuleDescriptionEntryContent + # since we know for certain that `entry.content` will not be None here. + entry.content = cast(RuleDescriptionEntryContent, entry.content) result = RuleProperties._from_internal_entity( rule_name, entry.content.rule_description ) @@ -1165,8 +1160,13 @@ def create_rule( ) # to remove after #3535 is released. return result - def update_rule(self, topic_name, subscription_name, rule, **kwargs): - # type: (str, str, Union[RuleProperties, Mapping[str, Any]], Any) -> None + def update_rule( + self, + topic_name: str, + subscription_name: str, + rule: Union[RuleProperties, Mapping[str, Any]], + **kwargs: Any + ) -> None: """Update a rule. Before calling this method, you should use `get_rule`, `create_rule` or `list_rules` to get a `RuleProperties` @@ -1202,13 +1202,13 @@ def update_rule(self, topic_name, subscription_name, rule, **kwargs): subscription_name, rule.name, request_body, - api_version=self._api_version, # type: ignore if_match="*", **kwargs ) - def delete_rule(self, topic_name, subscription_name, rule_name, **kwargs): - # type: (str, str, str, Any) -> None + def delete_rule( + self, topic_name: str, subscription_name: str, rule_name: str, **kwargs: Any + ) -> None: """Delete a topic subscription rule. :param str topic_name: The topic that owns the subscription. @@ -1221,16 +1221,11 @@ def delete_rule(self, topic_name, subscription_name, rule_name, **kwargs): topic_name, subscription_name, rule_name ) - self._impl.rule.delete( - topic_name, - subscription_name, - rule_name, - api_version=self._api_version, # type: ignore - **kwargs - ) + self._impl.rule.delete(topic_name, subscription_name, rule_name, **kwargs) - def list_rules(self, topic_name, subscription_name, **kwargs): - # type: (str, str, Any) -> ItemPaged[RuleProperties] + def list_rules( + self, topic_name: str, subscription_name: str, **kwargs: Any + ) -> ItemPaged[RuleProperties]: """List the rules of a topic subscription. :param str topic_name: The topic that owns the subscription. @@ -1258,23 +1253,22 @@ def entry_to_rule(ele, entry): get_next = functools.partial( get_next_template, functools.partial(self._impl.list_rules, topic_name, subscription_name), - api_version=self._api_version, # type: ignore **kwargs ) return ItemPaged(get_next, extract_data) - def get_namespace_properties(self, **kwargs): - # type: (Any) -> NamespaceProperties + def get_namespace_properties(self, **kwargs: Any) -> NamespaceProperties: """Get the namespace properties :rtype: ~azure.servicebus.management.NamespaceProperties """ - entry_el = self._impl.namespace.get(api_version=self._api_version, **kwargs) # type: ignore + entry_el = self._impl.namespace.get(**kwargs) # type: ignore namespace_entry = NamespacePropertiesEntry.deserialize(entry_el) + namespace_entry.content = cast(NamespacePropertiesEntryContent, namespace_entry.content) return NamespaceProperties._from_internal_entity( - namespace_entry.title, namespace_entry.content.namespace_properties + namespace_entry.title, + namespace_entry.content.namespace_properties ) - def close(self): - # type: () -> None + def close(self) -> None: self._impl.close() 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 32b5176a9dff..915bf618c5e0 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_model_workaround.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_model_workaround.py @@ -2,10 +2,9 @@ # 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, Optional, Tuple, Type, Union +from typing import Dict, Iterable, Any, Optional, Tuple, Type, Union, TYPE_CHECKING from collections import OrderedDict from datetime import timedelta -from msrest.serialization import Model ### The following section of this file is generated by a script and then formatted by BLACK. # The script is at ../../../swagger/generate_attributes_sequence_tuple.py. Use it at your own risk. @@ -46,8 +45,11 @@ TrueFilter, ) +if TYPE_CHECKING: + from ._generated._serialization import Model -MODEL_CLASS_ATTRIBUTES = { + +MODEL_CLASS_ATTRIBUTES: Dict[Type["Model"], Tuple[str, ...]] = { AuthorizationRule: ( "type", "claim_type", @@ -181,6 +183,7 @@ "auto_delete_on_idle", "entity_availability_status", "user_metadata", + "default_rule_description", ), SubscriptionDescriptionEntry: ( "id", @@ -236,7 +239,7 @@ "parameters", "requires_preprocessing", ), -} # type: Dict[Type[Model], Tuple[str, ...]] +} ### End of code generated by the script. diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_models.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_models.py index 2da6e2b7daf3..bff695b424f0 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_models.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_models.py @@ -9,7 +9,7 @@ from copy import deepcopy from datetime import datetime, timedelta from typing import Type, Dict, Any, Union, Optional, List -from msrest.serialization import Model +from ._generated._serialization import Model from ._generated.models import ( QueueDescription as InternalQueueDescription, @@ -27,10 +27,7 @@ AuthorizationRule as InternalAuthorizationRule, ) -from ._model_workaround import ( - adjust_attribute_map, - avoid_timedelta_overflow -) +from ._model_workaround import adjust_attribute_map, avoid_timedelta_overflow from ._constants import RULE_SQL_COMPATIBILITY_LEVEL from ._utils import _normalize_entity_path_to_full_path_if_needed @@ -289,7 +286,9 @@ def __init__(self, name, **kwargs): self.forward_dead_lettered_messages_to = extract_kwarg( "forward_dead_lettered_messages_to" ) - self.max_message_size_in_kilobytes = extract_kwarg("max_message_size_in_kilobytes") + self.max_message_size_in_kilobytes = extract_kwarg( + "max_message_size_in_kilobytes" + ) validate_extraction_missing_args(extraction_missing_args) @@ -321,7 +320,7 @@ def _from_internal_entity(cls, name, internal_qd): forward_to=internal_qd.forward_to, forward_dead_lettered_messages_to=internal_qd.forward_dead_lettered_messages_to, user_metadata=internal_qd.user_metadata, - max_message_size_in_kilobytes=internal_qd.max_message_size_in_kilobytes + max_message_size_in_kilobytes=internal_qd.max_message_size_in_kilobytes, ) qd._internal_qd = deepcopy(internal_qd) # pylint:disable=protected-access @@ -335,7 +334,9 @@ def _to_internal_entity(self, fully_qualified_namespace, kwargs=None): internal_qd = InternalQueueDescription() self._internal_qd = internal_qd - authorization_rules = kwargs.pop("authorization_rules", self.authorization_rules) + authorization_rules = kwargs.pop( + "authorization_rules", self.authorization_rules + ) self._internal_qd.authorization_rules = ( [r._to_internal_entity() for r in authorization_rules] if authorization_rules @@ -345,48 +346,67 @@ def _to_internal_entity(self, fully_qualified_namespace, kwargs=None): self._internal_qd.auto_delete_on_idle = avoid_timedelta_overflow( # type: ignore kwargs.pop("auto_delete_on_idle", self.auto_delete_on_idle) ) - self._internal_qd.dead_lettering_on_message_expiration = ( - kwargs.pop("dead_lettering_on_message_expiration", self.dead_lettering_on_message_expiration) + self._internal_qd.dead_lettering_on_message_expiration = kwargs.pop( + "dead_lettering_on_message_expiration", + self.dead_lettering_on_message_expiration, ) self._internal_qd.default_message_time_to_live = avoid_timedelta_overflow( # type: ignore - kwargs.pop("default_message_time_to_live", self.default_message_time_to_live) + kwargs.pop( + "default_message_time_to_live", self.default_message_time_to_live + ) + ) + self._internal_qd.duplicate_detection_history_time_window = kwargs.pop( + "duplicate_detection_history_time_window", + self.duplicate_detection_history_time_window, + ) + self._internal_qd.entity_availability_status = kwargs.pop( + "availability_status", self.availability_status + ) + self._internal_qd.enable_batched_operations = kwargs.pop( + "enable_batched_operations", self.enable_batched_operations + ) + self._internal_qd.enable_express = kwargs.pop( + "enable_express", self.enable_express ) - self._internal_qd.duplicate_detection_history_time_window = ( - kwargs.pop("duplicate_detection_history_time_window", self.duplicate_detection_history_time_window) + self._internal_qd.enable_partitioning = kwargs.pop( + "enable_partitioning", self.enable_partitioning ) - self._internal_qd.entity_availability_status = kwargs.pop("availability_status", self.availability_status) - self._internal_qd.enable_batched_operations = ( - kwargs.pop("enable_batched_operations", self.enable_batched_operations) + self._internal_qd.lock_duration = kwargs.pop( + "lock_duration", self.lock_duration ) - self._internal_qd.enable_express = kwargs.pop("enable_express", self.enable_express) - self._internal_qd.enable_partitioning = kwargs.pop("enable_partitioning", self.enable_partitioning) - self._internal_qd.lock_duration = kwargs.pop("lock_duration", self.lock_duration) - self._internal_qd.max_delivery_count = kwargs.pop("max_delivery_count", self.max_delivery_count) - self._internal_qd.max_size_in_megabytes = kwargs.pop("max_size_in_megabytes", self.max_size_in_megabytes) - self._internal_qd.requires_duplicate_detection = ( - kwargs.pop("requires_duplicate_detection", self.requires_duplicate_detection) + self._internal_qd.max_delivery_count = kwargs.pop( + "max_delivery_count", self.max_delivery_count + ) + self._internal_qd.max_size_in_megabytes = kwargs.pop( + "max_size_in_megabytes", self.max_size_in_megabytes + ) + self._internal_qd.requires_duplicate_detection = kwargs.pop( + "requires_duplicate_detection", self.requires_duplicate_detection + ) + self._internal_qd.requires_session = kwargs.pop( + "requires_session", self.requires_session ) - self._internal_qd.requires_session = kwargs.pop("requires_session", self.requires_session) self._internal_qd.status = kwargs.pop("status", self.status) forward_to = kwargs.pop("forward_to", self.forward_to) self._internal_qd.forward_to = _normalize_entity_path_to_full_path_if_needed( - forward_to, - fully_qualified_namespace + forward_to, fully_qualified_namespace ) - forward_dead_lettered_messages_to = ( - kwargs.pop("forward_dead_lettered_messages_to", self.forward_dead_lettered_messages_to) + forward_dead_lettered_messages_to = kwargs.pop( + "forward_dead_lettered_messages_to", self.forward_dead_lettered_messages_to ) - self._internal_qd.forward_dead_lettered_messages_to = _normalize_entity_path_to_full_path_if_needed( - forward_dead_lettered_messages_to, - fully_qualified_namespace + self._internal_qd.forward_dead_lettered_messages_to = ( + _normalize_entity_path_to_full_path_if_needed( + forward_dead_lettered_messages_to, fully_qualified_namespace + ) ) - self._internal_qd.user_metadata = kwargs.pop("user_metadata", self.user_metadata) + self._internal_qd.user_metadata = kwargs.pop( + "user_metadata", self.user_metadata + ) self._internal_qd.max_message_size_in_kilobytes = kwargs.pop( - "max_message_size_in_kilobytes", - self.max_message_size_in_kilobytes + "max_message_size_in_kilobytes", self.max_message_size_in_kilobytes ) return self._internal_qd @@ -585,7 +605,9 @@ def __init__(self, name, **kwargs): self.availability_status = extract_kwarg("availability_status") self.enable_express = extract_kwarg("enable_express") self.user_metadata = extract_kwarg("user_metadata") - self.max_message_size_in_kilobytes = extract_kwarg("max_message_size_in_kilobytes") + self.max_message_size_in_kilobytes = extract_kwarg( + "max_message_size_in_kilobytes" + ) validate_extraction_missing_args(extraction_missing_args) @@ -613,7 +635,7 @@ def _from_internal_entity(cls, name, internal_td): availability_status=internal_td.entity_availability_status, enable_express=internal_td.enable_express, user_metadata=internal_td.user_metadata, - max_message_size_in_kilobytes=internal_td.max_message_size_in_kilobytes + max_message_size_in_kilobytes=internal_td.max_message_size_in_kilobytes, ) td._internal_td = deepcopy(internal_td) return td @@ -625,38 +647,56 @@ def _to_internal_entity(self, kwargs=None): if not self._internal_td: self._internal_td = InternalTopicDescription() self._internal_td.default_message_time_to_live = avoid_timedelta_overflow( # type: ignore - kwargs.pop("default_message_time_to_live", self.default_message_time_to_live) + kwargs.pop( + "default_message_time_to_live", self.default_message_time_to_live + ) ) - self._internal_td.max_size_in_megabytes = kwargs.pop("max_size_in_megabytes", self.max_size_in_megabytes) - self._internal_td.requires_duplicate_detection = ( - kwargs.pop("requires_duplicate_detection", self.requires_duplicate_detection) + self._internal_td.max_size_in_megabytes = kwargs.pop( + "max_size_in_megabytes", self.max_size_in_megabytes ) - self._internal_td.duplicate_detection_history_time_window = ( - kwargs.pop("duplicate_detection_history_time_window", self.duplicate_detection_history_time_window) + self._internal_td.requires_duplicate_detection = kwargs.pop( + "requires_duplicate_detection", self.requires_duplicate_detection ) - self._internal_td.enable_batched_operations = ( - kwargs.pop("enable_batched_operations", self.enable_batched_operations) + self._internal_td.duplicate_detection_history_time_window = kwargs.pop( + "duplicate_detection_history_time_window", + self.duplicate_detection_history_time_window, + ) + self._internal_td.enable_batched_operations = kwargs.pop( + "enable_batched_operations", self.enable_batched_operations + ) + self._internal_td.size_in_bytes = kwargs.pop( + "size_in_bytes", self.size_in_bytes ) - self._internal_td.size_in_bytes = kwargs.pop("size_in_bytes", self.size_in_bytes) - authorization_rules = kwargs.pop("authorization_rules", self.authorization_rules) + authorization_rules = kwargs.pop( + "authorization_rules", self.authorization_rules + ) self._internal_td.authorization_rules = ( [r._to_internal_entity() for r in authorization_rules] if authorization_rules else authorization_rules ) self._internal_td.status = kwargs.pop("status", self.status) - self._internal_td.support_ordering = kwargs.pop("support_ordering", self.support_ordering) + self._internal_td.support_ordering = kwargs.pop( + "support_ordering", self.support_ordering + ) self._internal_td.auto_delete_on_idle = avoid_timedelta_overflow( # type: ignore kwargs.pop("auto_delete_on_idle", self.auto_delete_on_idle) ) - self._internal_td.enable_partitioning = kwargs.pop("enable_partitioning", self.enable_partitioning) - self._internal_td.entity_availability_status = kwargs.pop("availability_status", self.availability_status) - self._internal_td.enable_express = kwargs.pop("enable_express", self.enable_express) - self._internal_td.user_metadata = kwargs.pop("user_metadata", self.user_metadata) + self._internal_td.enable_partitioning = kwargs.pop( + "enable_partitioning", self.enable_partitioning + ) + self._internal_td.entity_availability_status = kwargs.pop( + "availability_status", self.availability_status + ) + self._internal_td.enable_express = kwargs.pop( + "enable_express", self.enable_express + ) + self._internal_td.user_metadata = kwargs.pop( + "user_metadata", self.user_metadata + ) self._internal_td.max_message_size_in_kilobytes = kwargs.pop( - "max_message_size_in_kilobytes", - self.max_message_size_in_kilobytes + "max_message_size_in_kilobytes", self.max_message_size_in_kilobytes ) return self._internal_td @@ -823,14 +863,14 @@ def __init__(self, name, **kwargs): @classmethod def _from_internal_entity(cls, name, internal_subscription): # type: (str, InternalSubscriptionDescription) -> SubscriptionProperties + # pylint: disable=line-too-long subscription = cls( name, lock_duration=internal_subscription.lock_duration, requires_session=internal_subscription.requires_session, default_message_time_to_live=internal_subscription.default_message_time_to_live, dead_lettering_on_message_expiration=internal_subscription.dead_lettering_on_message_expiration, - dead_lettering_on_filter_evaluation_exceptions= - internal_subscription.dead_lettering_on_filter_evaluation_exceptions, + dead_lettering_on_filter_evaluation_exceptions=internal_subscription.dead_lettering_on_filter_evaluation_exceptions, max_delivery_count=internal_subscription.max_delivery_count, enable_batched_operations=internal_subscription.enable_batched_operations, status=internal_subscription.status, @@ -849,45 +889,56 @@ def _to_internal_entity(self, fully_qualified_namespace, kwargs=None): if not self._internal_sd: self._internal_sd = InternalSubscriptionDescription() - self._internal_sd.lock_duration = kwargs.pop("lock_duration", self.lock_duration) - self._internal_sd.requires_session = kwargs.pop("requires_session", self.requires_session) - self._internal_sd.default_message_time_to_live = avoid_timedelta_overflow( # type: ignore - kwargs.pop("default_message_time_to_live", self.default_message_time_to_live) + self._internal_sd.lock_duration = kwargs.pop( + "lock_duration", self.lock_duration ) - self._internal_sd.dead_lettering_on_message_expiration = ( - kwargs.pop("dead_lettering_on_message_expiration", self.dead_lettering_on_message_expiration) + self._internal_sd.requires_session = kwargs.pop( + "requires_session", self.requires_session ) - self._internal_sd.dead_lettering_on_filter_evaluation_exceptions = ( + self._internal_sd.default_message_time_to_live = avoid_timedelta_overflow( # type: ignore kwargs.pop( - "dead_lettering_on_filter_evaluation_exceptions", - self.dead_lettering_on_filter_evaluation_exceptions + "default_message_time_to_live", self.default_message_time_to_live ) ) - self._internal_sd.max_delivery_count = kwargs.pop("max_delivery_count", self.max_delivery_count) - self._internal_sd.enable_batched_operations = ( - kwargs.pop("enable_batched_operations", self.enable_batched_operations) + self._internal_sd.dead_lettering_on_message_expiration = kwargs.pop( + "dead_lettering_on_message_expiration", + self.dead_lettering_on_message_expiration, + ) + self._internal_sd.dead_lettering_on_filter_evaluation_exceptions = kwargs.pop( + "dead_lettering_on_filter_evaluation_exceptions", + self.dead_lettering_on_filter_evaluation_exceptions, + ) + self._internal_sd.max_delivery_count = kwargs.pop( + "max_delivery_count", self.max_delivery_count + ) + self._internal_sd.enable_batched_operations = kwargs.pop( + "enable_batched_operations", self.enable_batched_operations ) self._internal_sd.status = kwargs.pop("status", self.status) forward_to = kwargs.pop("forward_to", self.forward_to) self._internal_sd.forward_to = _normalize_entity_path_to_full_path_if_needed( - forward_to, - fully_qualified_namespace + forward_to, fully_qualified_namespace ) - forward_dead_lettered_messages_to = ( - kwargs.pop("forward_dead_lettered_messages_to", self.forward_dead_lettered_messages_to) + forward_dead_lettered_messages_to = kwargs.pop( + "forward_dead_lettered_messages_to", self.forward_dead_lettered_messages_to ) - self._internal_sd.forward_dead_lettered_messages_to = _normalize_entity_path_to_full_path_if_needed( - forward_dead_lettered_messages_to, - fully_qualified_namespace + self._internal_sd.forward_dead_lettered_messages_to = ( + _normalize_entity_path_to_full_path_if_needed( + forward_dead_lettered_messages_to, fully_qualified_namespace + ) ) - self._internal_sd.user_metadata = kwargs.pop("user_metadata", self.user_metadata) + self._internal_sd.user_metadata = kwargs.pop( + "user_metadata", self.user_metadata + ) self._internal_sd.auto_delete_on_idle = avoid_timedelta_overflow( # type: ignore kwargs.pop("auto_delete_on_idle", self.auto_delete_on_idle) ) - self._internal_sd.entity_availability_status = kwargs.pop("availability_status", self.availability_status) + self._internal_sd.entity_availability_status = kwargs.pop( + "availability_status", self.availability_status + ) return self._internal_sd @@ -1051,7 +1102,9 @@ def _to_internal_entity(self, kwargs=None): action._to_internal_entity() if action else EMPTY_RULE_ACTION ) - self._internal_rule.created_at = kwargs.pop("created_at_utc", self.created_at_utc) + self._internal_rule.created_at = kwargs.pop( + "created_at_utc", self.created_at_utc + ) self._internal_rule.name = kwargs.pop("name", self.name) return self._internal_rule diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_utils.py b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_utils.py index a4da776261a6..60ac619d04bf 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/management/_utils.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/management/_utils.py @@ -8,7 +8,6 @@ import isodate from . import _constants as constants -from ._api_version import DEFAULT_VERSION from ._handle_response_error import _handle_response_error if TYPE_CHECKING: @@ -84,18 +83,14 @@ def get_next_template(list_func, *args, **kwargs): """ start_index = kwargs.pop("start_index", 0) max_page_size = kwargs.pop("max_page_size", 100) - api_version = kwargs.pop("api_version", DEFAULT_VERSION) if args[0]: queries = urlparse.parse_qs(urlparse.urlparse(args[0]).query) start_index = int(queries[constants.LIST_OP_SKIP][0]) max_page_size = int(queries[constants.LIST_OP_TOP][0]) - api_version = queries[constants.API_VERSION_PARAM_NAME][0] with _handle_response_error(): feed_element = cast( ElementTree, - list_func( - skip=start_index, top=max_page_size, api_version=api_version, **kwargs - ), + list_func(skip=start_index, top=max_page_size, **kwargs), ) return feed_element diff --git a/sdk/servicebus/azure-servicebus/setup.py b/sdk/servicebus/azure-servicebus/setup.py index f0d37123ba37..b940b9e6ec68 100644 --- a/sdk/servicebus/azure-servicebus/setup.py +++ b/sdk/servicebus/azure-servicebus/setup.py @@ -65,10 +65,8 @@ ]), install_requires=[ "uamqp>=1.6.3,<2.0.0", - 'azure-common~=1.1', - 'msrest>=0.6.17,<2.0.0', - 'azure-core<2.0.0,>=1.14.0', + "azure-core<2.0.0,>=1.24.0", "isodate>=0.6.0", - "typing-extensions>=3.7.4.3", + "typing-extensions>=4.0.1", ] ) diff --git a/sdk/servicebus/azure-servicebus/swagger/README.md b/sdk/servicebus/azure-servicebus/swagger/README.md index b940005b6e95..4a3d39baa698 100644 --- a/sdk/servicebus/azure-servicebus/swagger/README.md +++ b/sdk/servicebus/azure-servicebus/swagger/README.md @@ -5,16 +5,17 @@ ### Generation ```ps cd C:\Work\ServiceBus\ -autorest --v3 --python --use=@autorest/python@5.0.0-preview.6 +autorest --reset +autorest swagger/README.md ``` ### Settings ``` yaml -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/sb_dataplane_namespace/specification/servicebus/data-plane/servicebus-swagger.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/servicebus/data-plane/Microsoft.ServiceBus/stable/2021-05/servicebus.json output-folder: ../azure/servicebus/management/_generated namespace: azure.servicebus.management._generated no-namespace-folders: true license-header: MICROSOFT_MIT_NO_VERSION clear-output-folder: true python: true -package-version: "2021-05" +models-mode: msrest ``` diff --git a/sdk/servicebus/azure-servicebus/swagger/generate_attributes_sequence_tuple.py b/sdk/servicebus/azure-servicebus/swagger/generate_attributes_sequence_tuple.py index a5a385366bd6..88e6c7000983 100644 --- a/sdk/servicebus/azure-servicebus/swagger/generate_attributes_sequence_tuple.py +++ b/sdk/servicebus/azure-servicebus/swagger/generate_attributes_sequence_tuple.py @@ -13,12 +13,12 @@ # _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 +from azure.servicebus.management._generated._serialization import Model +from azure.servicebus.management._generated.models import _models if __name__ == '__main__': - members = inspect.getmembers(_models_py3, inspect.isclass) + members = inspect.getmembers(_models, inspect.isclass) class_names = [] model_class_attributes_string = "MODEL_CLASS_ATTRIBUTES = {\n" for class_name, class_ in members: diff --git a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_queues_async.py b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_queues_async.py index ef14a4f2f4ba..fa1836cf00e8 100644 --- a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_queues_async.py +++ b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_queues_async.py @@ -6,7 +6,6 @@ import pytest import datetime -import msrest from azure.core.exceptions import HttpResponseError, ResourceNotFoundError, ResourceExistsError from azure.servicebus.aio.management import ServiceBusAdministrationClient from azure.servicebus.management import ApiVersion @@ -211,10 +210,10 @@ async def test_async_mgmt_queue_create_by_name(self, servicebus_connection_str, async def test_async_mgmt_queue_create_with_invalid_name(self, servicebus_connection_str, **kwargs): mgmt_service = ServiceBusAdministrationClient.from_connection_string(servicebus_connection_str) - with pytest.raises(msrest.exceptions.ValidationError): + with pytest.raises(HttpResponseError): await mgmt_service.create_queue(Exception()) - with pytest.raises(msrest.exceptions.ValidationError): + with pytest.raises(HttpResponseError): await mgmt_service.create_queue('') @ServiceBusPreparer() @@ -563,7 +562,7 @@ async def test_async_mgmt_queue_update_invalid(self, servicebus_connection_str, #change the name to a queue with an invalid name exist; should fail. queue_description.name = '' - with pytest.raises(msrest.exceptions.ValidationError): + with pytest.raises(HttpResponseError): await mgmt_service.update_queue(queue_description) queue_description.name = queue_name @@ -654,7 +653,7 @@ async def test_async_mgmt_queue_get_runtime_properties_negative(self, servicebus with pytest.raises(TypeError): await mgmt_service.get_queue_runtime_properties(None) - with pytest.raises(msrest.exceptions.ValidationError): + with pytest.raises(HttpResponseError): await mgmt_service.get_queue_runtime_properties("") with pytest.raises(ResourceNotFoundError): diff --git a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_rules_async.py b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_rules_async.py index c6dd9ebd6057..43d33823452d 100644 --- a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_rules_async.py +++ b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_rules_async.py @@ -8,7 +8,6 @@ import pytest -import msrest from azure.servicebus.aio.management import ServiceBusAdministrationClient from azure.servicebus.management import RuleProperties, CorrelationRuleFilter, SqlRuleFilter, TrueRuleFilter, SqlRuleAction from azure.servicebus.management._constants import INT32_MAX_VALUE @@ -203,7 +202,7 @@ async def test_async_mgmt_rule_update_invalid(self, servicebus_connection_str, * # change the name to a topic with an invalid name exist; should fail. rule_desc.name = '' - with pytest.raises(msrest.exceptions.ValidationError): + with pytest.raises(HttpResponseError): await mgmt_service.update_rule(topic_name, subscription_description.name, rule_desc) rule_desc.name = rule_name diff --git a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_subscriptions_async.py b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_subscriptions_async.py index 98f60f9fe4a5..e054815cad4e 100644 --- a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_subscriptions_async.py +++ b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_subscriptions_async.py @@ -7,7 +7,6 @@ import pytest import datetime -import msrest from azure.servicebus.aio.management import ServiceBusAdministrationClient from azure.servicebus.management import SubscriptionProperties from utilities import get_logger @@ -277,7 +276,7 @@ async def test_async_mgmt_subscription_update_invalid(self, servicebus_connectio # change the name to a topic with an invalid name exist; should fail. subscription_description.name = '' - with pytest.raises(msrest.exceptions.ValidationError): + with pytest.raises(HttpResponseError): await mgmt_service.update_subscription(topic_name, subscription_description) subscription_description.name = topic_name diff --git a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_topics_async.py b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_topics_async.py index 5c59ba7e8b0b..35ea48daafee 100644 --- a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_topics_async.py +++ b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_topics_async.py @@ -7,7 +7,6 @@ import pytest import datetime -import msrest from azure.servicebus.aio.management import ServiceBusAdministrationClient from azure.servicebus.management import TopicProperties from azure.servicebus.aio._base_handler_async import ServiceBusSharedKeyCredential @@ -285,7 +284,7 @@ async def test_async_mgmt_topic_update_invalid(self, servicebus_connection_str, # change the name to a topic with an invalid name exist; should fail. topic_description.name = '' - with pytest.raises(msrest.exceptions.ValidationError): + with pytest.raises(HttpResponseError): await mgmt_service.update_topic(topic_description) topic_description.name = topic_name diff --git a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_queues.py b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_queues.py index fc2ad9431dc6..0a3389e82558 100644 --- a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_queues.py +++ b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_queues.py @@ -10,11 +10,10 @@ import datetime import functools -import msrest from azure.servicebus.management import ServiceBusAdministrationClient, QueueProperties, ApiVersion from azure.servicebus._common.utils import utc_now from utilities import get_logger -from azure.core.exceptions import HttpResponseError, ServiceRequestError, ResourceNotFoundError, ResourceExistsError +from azure.core.exceptions import HttpResponseError, ResourceNotFoundError, ResourceExistsError from azure.servicebus._base_handler import ServiceBusSharedKeyCredential from devtools_testutils import AzureMgmtRecordedTestCase, CachedResourceGroupPreparer, recorded_by_proxy @@ -214,11 +213,11 @@ def test_mgmt_queue_create_by_name(self, servicebus_connection_str, **kwargs): def test_mgmt_queue_create_with_invalid_name(self, servicebus_connection_str, **kwargs): mgmt_service = ServiceBusAdministrationClient.from_connection_string(servicebus_connection_str) - with pytest.raises(msrest.exceptions.ValidationError): + with pytest.raises(HttpResponseError): mgmt_service.create_queue(Exception()) - with pytest.raises(msrest.exceptions.ValidationError): + with pytest.raises(HttpResponseError): mgmt_service.create_queue('') @ServiceBusPreparer() @@ -578,7 +577,7 @@ def test_mgmt_queue_update_invalid(self, servicebus_connection_str, **kwargs): #change the name to a queue with an invalid name exist; should fail. queue_description.name = '' - with pytest.raises(msrest.exceptions.ValidationError): + with pytest.raises(HttpResponseError): mgmt_service.update_queue(queue_description) queue_description.name = queue_name @@ -672,7 +671,7 @@ def test_mgmt_queue_get_runtime_properties_negative(self, servicebus_connection_ with pytest.raises(TypeError): mgmt_service.get_queue_runtime_properties(None) - with pytest.raises(msrest.exceptions.ValidationError): + with pytest.raises(HttpResponseError): mgmt_service.get_queue_runtime_properties("") with pytest.raises(ResourceNotFoundError): diff --git a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_rules.py b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_rules.py index 14d87c85c726..16c0b9b15d3e 100644 --- a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_rules.py +++ b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_rules.py @@ -7,7 +7,6 @@ import pytest from datetime import datetime, timedelta -import msrest from azure.servicebus.management import ServiceBusAdministrationClient, RuleProperties, CorrelationRuleFilter, SqlRuleFilter, TrueRuleFilter, FalseRuleFilter, SqlRuleAction from azure.servicebus.management._constants import INT32_MAX_VALUE from utilities import get_logger @@ -219,7 +218,7 @@ def test_mgmt_rule_update_invalid(self, servicebus_connection_str, **kwargs): # change the name to a topic with an invalid name exist; should fail. rule_desc.name = '' - with pytest.raises(msrest.exceptions.ValidationError): + with pytest.raises(HttpResponseError): mgmt_service.update_rule(topic_name, subscription_description.name, rule_desc) rule_desc.name = rule_name diff --git a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_subscriptions.py b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_subscriptions.py index 5be2753b3264..26915a4dd660 100644 --- a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_subscriptions.py +++ b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_subscriptions.py @@ -7,7 +7,6 @@ import pytest import datetime -import msrest from azure.servicebus.management import ServiceBusAdministrationClient, SubscriptionProperties from utilities import get_logger from azure.core.exceptions import HttpResponseError, ResourceExistsError @@ -274,7 +273,7 @@ def test_mgmt_subscription_update_invalid(self, servicebus_connection_str, **kwa # change the name to a topic with an invalid name exist; should fail. subscription_description.name = '' - with pytest.raises(msrest.exceptions.ValidationError): + with pytest.raises(HttpResponseError): mgmt_service.update_subscription(topic_name, subscription_description) subscription_description.name = topic_name diff --git a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_topics.py b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_topics.py index 43e02bc848c8..e99e2169c105 100644 --- a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_topics.py +++ b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_topics.py @@ -7,7 +7,6 @@ import pytest import datetime -import msrest from azure.servicebus.management import ServiceBusAdministrationClient, TopicProperties, ApiVersion from azure.servicebus._base_handler import ServiceBusSharedKeyCredential from utilities import get_logger @@ -291,7 +290,7 @@ def test_mgmt_topic_update_invalid(self, servicebus_connection_str, **kwargs): # change the name to a topic with an invalid name exist; should fail. topic_description.name = '' - with pytest.raises(msrest.exceptions.ValidationError): + with pytest.raises(HttpResponseError): mgmt_service.update_topic(topic_description) topic_description.name = topic_name